Facebook
From Wiki, 1 Year ago, written in Lua.
Embed
Download Paste or View Raw
Hits: 127
  1. --Put script in autoexecute folder or it wont work.
  2.  
  3. local plyrs = game:GetService("Players")
  4. local rs = game:GetService("RunService")
  5. local uis = game:GetService("UserInputService")
  6. local cam = workspace.Camera
  7. local headset
  8. local p
  9.  
  10. local bodybinds = {
  11.         [Enum.KeyCode.Q] = "lHand",
  12.         [Enum.KeyCode.E] = "rHand",
  13.         [Enum.KeyCode.W] = Vector3.new(0, 1, 0),
  14.         [Enum.KeyCode.A] = Vector3.new(-1, 0, 0),
  15.         [Enum.KeyCode.S] = Vector3.new(0, -1, 0),
  16.         [Enum.KeyCode.D] = Vector3.new(1, 0, 0),
  17.         [Enum.KeyCode.G] = false,
  18.         [Enum.KeyCode.F] = true,
  19.         [Enum.KeyCode.LeftShift] = 1,
  20.         [Enum.KeyCode.LeftControl] = 2,
  21.         [Enum.KeyCode.LeftAlt] = 3
  22. }
  23.  
  24. local gesturebinds = {
  25.         "Fist",
  26.         "Index",
  27.         "Thumb"
  28. }
  29.  
  30. local body = setmetatable({ -- least fav part of the script
  31.         lastHand = "",
  32.         lHand = {
  33.                 false,
  34.                 CFrame.new(-math.cos(math.pi / 4), -0.5, -math.sin(math.pi / 4)),
  35.                 0
  36.         },
  37.         rHand = {
  38.                 false,
  39.                 CFrame.new(-math.cos(3 * math.pi / 4), -0.5, -math.sin(3 * math.pi / 4)),
  40.                 0
  41.         }
  42. }, {
  43.         __call = function(t, k, mult)
  44.                 mult = mult or 1
  45.  
  46.                 local bind = bodybinds[k]
  47.                 if bind and headset then
  48.                         if typeof(bind) == "string" then
  49.                                 t[bind][1] = mult > 0
  50.  
  51.                                 lastHand = mult > 0 and bind or lastHand
  52.  
  53.                         elseif typeof(bind) == "Vector3" then
  54.                                 headset.StickPosition += bind * mult
  55.                         elseif typeof(bind) == "boolean" then
  56.                                 headset.Stick2 = mult > 0 and bind and 1 or 0
  57.                         elseif typeof(bind) == "number" and lastHand:len() > 0 then
  58.                                 local gesture = lastHand:sub(1,1)..gesturebinds[bind]
  59.  
  60.                                 if mult > 0 then
  61.                                         headset[gesture] = headset[gesture] == 0 and 1 or 0
  62.                                 end
  63.                         end
  64.                 end
  65.         end
  66. })
  67.  
  68. local ind, nc, nind
  69.  
  70. local events = {}
  71.  
  72. local cfs = {
  73.         [Enum.UserCFrame.Head] = CFrame.new(0, 0, 0),
  74.         [Enum.UserCFrame.LeftHand] = CFrame.new(-1, 0, -1),
  75.         [Enum.UserCFrame.RightHand] = CFrame.new(1, 0, -1)
  76.  
  77. }
  78.  
  79. local realVrService = game:GetService("VRService")
  80.  
  81. local fakeVrService = setmetatable({
  82.         VREnabled = true,
  83.         SetTouchpadMode = function()
  84.         end,
  85.         RecenterUserHeadCFrame = function()
  86.         end,
  87.         GetUserCFrameEnabled = function(cf)
  88.                 return true
  89.         end,
  90.         GetUserCFrame = function(cf)
  91.                 return cfs[cf] or CFrame.new(0, 0, 0)
  92.         end
  93.  
  94. }, {
  95.         __index = function(t, k)
  96.                 local real = ind(realVrService, k)
  97.                 if typeof(real) == "RBXScriptSignal" then
  98.                         events[k] = events[k] or {
  99.                                 Name = k,
  100.                                 Connect = function(t, f)
  101.                                         t.Function = f
  102.  
  103.                                         if t.Name == "UserCFrameChanged" then
  104.                                                 headset = debug.getupvalue(t.Function, 1)
  105.  
  106.                                                 debug.setupvalue(headset.UpdateHand, 5, setmetatable({}, {
  107.                                                         __index = function(t, k)
  108.                                                                 return cam[k]
  109.                                                         end,
  110.                                                         __newindex = function(t, k, v)
  111.                                                                 if cam.CameraType == Enum.CameraType.Scriptable and p then -- unfortunately the first time this will run may or may not be before the cameratype is set
  112.                                                                         cam.CameraType = Enum.CameraType.Custom
  113.                                                                         cam.CameraSubject = headset.Head
  114.                                                                 end
  115.  
  116.                                                                 if k ~= "CFrame" then -- fuck you
  117.                                                                         cam[k] = v
  118.                                                                 end
  119.                                                         end
  120.                                                 }))
  121.  
  122.                                                 cam:GetPropertyChangedSignal("CameraSubject"):connect(function()
  123.                                                         if cam.CameraSubject ~= headset.Head then
  124.                                                                 cam.CameraSubject = headset.Head
  125.                                                         end
  126.                                                 end)
  127.                                         end
  128.  
  129.                                 end,
  130.                                 Fire = function(t, ...)
  131.                                         return t.Function(...)
  132.                                 end
  133.                         }
  134.  
  135.                         return events[k]
  136.                 end
  137.  
  138.                 return real
  139.         end,
  140.         __call = function(t, method, vr, ...)
  141.                 return t[method](...)
  142.         end
  143. })
  144.  
  145. ind = hookmetamethod(game, "__index", function(...)
  146.         local t, k = ...
  147.  
  148.         local scr = getcallingscript()
  149.  
  150.         if t == realVrService and not (scr and ind(scr, "Name") == "CameraModule") then
  151.                 return fakeVrService[k]
  152.         end
  153.  
  154.         return ind(...)
  155. end)
  156.  
  157. nc = hookmetamethod(game, "__namecall", function(...)
  158.         local t = ...
  159.  
  160.         if t == realVrService then
  161.                 local method = getnamecallmethod()
  162.                 return fakeVrService(method, ...)
  163.         end
  164.  
  165.         return nc(...)
  166. end)
  167.  
  168. nind = hookmetamethod(game, "__newindex", function(...)
  169.         local t, k, v = ...
  170.  
  171.         if t == cam and k == "CFrame" and events.UserCFrameChanged then
  172.                 events.UserCFrameChanged:Fire(Enum.UserCFrame.Head, CFrame.Angles(cam.CFrame:ToEulerAnglesXYZ()))
  173.         end
  174.  
  175.         nind(t, k, v)
  176. end)
  177.  
  178.  
  179.  
  180. uis.InputBegan:connect(function(i) -- also least favorite
  181.         if headset then
  182.                 if i.UserInputType == Enum.UserInputType.Keyboard then
  183.                         body(i.KeyCode)
  184.                 elseif i.UserInputType == Enum.UserInputType.MouseButton1 or i.UserInputType == Enum.UserInputType.MouseButton2 or i.UserInputType == Enum.UserInputType.MouseButton3 then
  185.                         body(i.UserInputType)
  186.                 end
  187.         end
  188. end)
  189.  
  190. uis.InputEnded:connect(function(i)
  191.         if headset then
  192.                 if i.UserInputType == Enum.UserInputType.Keyboard then
  193.                         body(i.KeyCode, -1)
  194.                 elseif i.UserInputType == Enum.UserInputType.MouseButton1 or i.UserInputType == Enum.UserInputType.MouseButton2 or i.UserInputType == Enum.UserInputType.MouseButton3 then
  195.                         body(i.UserInputType, -1)
  196.                 end
  197.         end
  198. end)
  199.  
  200. rs:BindToRenderStep(game:GetService("HttpService"):GenerateGUID(), Enum.RenderPriority.Camera.Value - 1, function() -- at least it works
  201.         if events.UserCFrameChanged and headset then
  202.                 local mpos = uis:GetMouseLocation()
  203.  
  204.                 local cursordir = cam:ViewportPointToRay(mpos.x, mpos.y).Direction
  205.  
  206.                 body.lHand[3] = body.lHand[1] and math.clamp(body.lHand[3] + 0.05, 0, 1) or body.lHand[3] > 0 and math.clamp(body.lHand[3] - 0.05, 0, 1) or body.lHand[3]
  207.                 body.rHand[3] = body.rHand[1] and math.clamp(body.rHand[3] + 0.05, 0, 1) or body.rHand[3] > 0 and math.clamp(body.rHand[3] - 0.05, 0, 1) or body.rHand[3]
  208.  
  209.                 local theta = math.acos(Vector3.new(-1, 0, 0):Dot((cam.CFrame.LookVector * Vector3.new(1, 0, 1)).unit))
  210.  
  211.                 theta = cam.CFrame.LookVector.z > 0 and (2 * math.pi) - theta or theta
  212.  
  213.  
  214.                 body.lHand[2] = CFrame.new(-math.cos(theta - (math.pi / 4)), -0.5, -math.sin(theta - (math.pi / 4)))
  215.                 body.rHand[2] = CFrame.new(-math.cos(theta + (math.pi / 4)), -0.5, -math.sin(theta + (math.pi / 4)))
  216.  
  217.                 local lcf = ((body.lHand[2]):lerp(CFrame.new(cursordir * 100 / cam.HeadScale), body.lHand[3]))
  218.                 local rcf = ((body.rHand[2]):lerp(CFrame.new(cursordir * 100 / cam.HeadScale), body.rHand[3]))
  219.  
  220.                 events.UserCFrameChanged:Fire(Enum.UserCFrame.LeftHand, lcf * CFrame.Angles(cam.CFrame:ToEulerAnglesXYZ()))
  221.                 events.UserCFrameChanged:Fire(Enum.UserCFrame.RightHand, rcf * CFrame.Angles(cam.CFrame:ToEulerAnglesXYZ()))
  222.         end
  223. end)
  224.  
  225. p = plyrs.LocalPlayer or (function()
  226.         plyrs:GetPropertyChangedSignal("LocalPlayer"):wait() -- this doesnt return anything for some reason??
  227.         return plyrs.LocalPlayer
  228. end)()