Advertisement
TheYoutuber_Pro

vr

Apr 18th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. local Instance = {new = function(a,b)
  2.  
  3. local Parent = nil
  4. local prt = Instance.new(a)
  5. if typeof(b) == "Instance" then
  6. Parent = b
  7. prt.Parent = b
  8. else
  9. for i,v in pairs(b) do
  10. if i ~= "Parent" then
  11. prt[i] = v
  12. else
  13. Parent = v
  14. end
  15. end
  16. end
  17. prt.Parent = Parent
  18. return prt
  19. end,}
  20.  
  21. local char = owner.Character
  22.  
  23. local head = char.Head
  24. local lArm = char["Left Arm"]
  25. local rArm = char["Right Arm"]
  26.  
  27. local bps = {head,lArm,rArm}
  28.  
  29. function createVelocities(obj)
  30. local bodyGyro = Instance.new("BodyGyro",{Parent = obj,Name = "G",P = 150000,D = 1000,MaxTorque = Vector3.new(math.huge,math.huge,math.huge),CFrame = head.CFrame})
  31. local bodyPos = Instance.new("BodyPosition",{Parent = obj,Name = "P",P = 150000,D = 1000,MaxForce = Vector3.new(math.huge,math.huge,math.huge),Position = head.Position})
  32. obj:SetNetworkOwner(owner)
  33. end
  34. local mod = Instance.new("Model",{Name = owner.Name.."'s vr guy!",Parent = script})
  35. for _,v in next,bps do
  36. v.Parent = mod
  37. v.CanCollide = true
  38. createVelocities(v)
  39. end
  40. owner.Character:Remove()
  41.  
  42. local value = Instance.new("ObjectValue",owner.PlayerGui)
  43. value.Value = mod
  44.  
  45. script.Parent = workspace
  46.  
  47. NLS([[
  48. local plr = game:GetService'Players'.LocalPlayer
  49. local mouse = plr:GetMouse()
  50. local char = script.Parent.Value
  51. local Cam = workspace.CurrentCamera
  52.  
  53. local UIS = game:GetService'UserInputService'
  54. local VrEnabled = UIS.VREnabled
  55.  
  56.  
  57. local head = char.Head
  58. local lArm = char["Left Arm"]
  59. local rArm = char["Right Arm"]
  60. local BPS = {head,lArm,rArm}
  61. for _,v in next,BPS do v.CanCollide = false end
  62.  
  63. function editCF(obj,cf)
  64. obj.G.CFrame = cf
  65. obj.P.Position = cf.Position
  66. end
  67.  
  68. local CurrentCF = {
  69. Head = head.CFrame,
  70. LArm = lArm.CFrame,
  71. RArm = rArm.CFrame,
  72. }
  73. workspace.CurrentCamera.CameraSubject = head
  74.  
  75. function getRotationCF(cf)
  76. cf = cf-cf.Position
  77. return cf
  78. end
  79.  
  80. function applyCFrames()
  81. editCF(head,CurrentCF.Head)
  82. editCF(lArm,CurrentCF.LArm)
  83. editCF(rArm,CurrentCF.RArm)
  84. end
  85.  
  86. local Directions = {
  87. Forwards = 0,
  88. Right = 0,
  89. Left = 0,
  90. Backwards = 0,
  91. }
  92. function KeysFunctions(k,m)
  93. if not VREnabled then
  94. k = k:lower()
  95. if k == "w" then
  96. Directions.Forwards = m
  97. elseif k == "s" then
  98. Directions.Backwards = m
  99. elseif k == "d" then
  100. Directions.Right = m
  101. elseif k == "a" then
  102. Directions.Left = m
  103. end
  104. end
  105. end
  106.  
  107. mouse.KeyDown:Connect(function(k)
  108. KeysFunctions(k,.1)
  109. end)
  110. mouse.KeyUp:Connect(function(k)
  111. KeysFunctions(k,0)
  112. end)
  113.  
  114. game:GetService'RunService'.RenderStepped:Connect(function()
  115. if not VREnabled then
  116. CurrentCF.Head *= CFrame.new(Directions.Right,0,-Directions.Forwards)
  117. CurrentCF.Head *= CFrame.new(-Directions.Left,0,Directions.Backwards)
  118. CurrentCF.Head = CFrame.new(CurrentCF.Head.Position) * getRotationCF(Cam.CFrame)
  119. end
  120. applyCFrames()
  121. end)
  122.  
  123.  
  124. ]],value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement