Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Instance = {new = function(a,b)
- local Parent = nil
- local prt = Instance.new(a)
- if typeof(b) == "Instance" then
- Parent = b
- prt.Parent = b
- else
- for i,v in pairs(b) do
- if i ~= "Parent" then
- prt[i] = v
- else
- Parent = v
- end
- end
- end
- prt.Parent = Parent
- return prt
- end,}
- local char = owner.Character
- local head = char.Head
- local lArm = char["Left Arm"]
- local rArm = char["Right Arm"]
- local bps = {head,lArm,rArm}
- function createVelocities(obj)
- 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})
- 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})
- obj:SetNetworkOwner(owner)
- end
- local mod = Instance.new("Model",{Name = owner.Name.."'s vr guy!",Parent = script})
- for _,v in next,bps do
- v.Parent = mod
- v.CanCollide = true
- createVelocities(v)
- end
- owner.Character:Remove()
- local value = Instance.new("ObjectValue",owner.PlayerGui)
- value.Value = mod
- script.Parent = workspace
- NLS([[
- local plr = game:GetService'Players'.LocalPlayer
- local mouse = plr:GetMouse()
- local char = script.Parent.Value
- local Cam = workspace.CurrentCamera
- local UIS = game:GetService'UserInputService'
- local VrEnabled = UIS.VREnabled
- local head = char.Head
- local lArm = char["Left Arm"]
- local rArm = char["Right Arm"]
- local BPS = {head,lArm,rArm}
- for _,v in next,BPS do v.CanCollide = false end
- function editCF(obj,cf)
- obj.G.CFrame = cf
- obj.P.Position = cf.Position
- end
- local CurrentCF = {
- Head = head.CFrame,
- LArm = lArm.CFrame,
- RArm = rArm.CFrame,
- }
- workspace.CurrentCamera.CameraSubject = head
- function getRotationCF(cf)
- cf = cf-cf.Position
- return cf
- end
- function applyCFrames()
- editCF(head,CurrentCF.Head)
- editCF(lArm,CurrentCF.LArm)
- editCF(rArm,CurrentCF.RArm)
- end
- local Directions = {
- Forwards = 0,
- Right = 0,
- Left = 0,
- Backwards = 0,
- }
- function KeysFunctions(k,m)
- if not VREnabled then
- k = k:lower()
- if k == "w" then
- Directions.Forwards = m
- elseif k == "s" then
- Directions.Backwards = m
- elseif k == "d" then
- Directions.Right = m
- elseif k == "a" then
- Directions.Left = m
- end
- end
- end
- mouse.KeyDown:Connect(function(k)
- KeysFunctions(k,.1)
- end)
- mouse.KeyUp:Connect(function(k)
- KeysFunctions(k,0)
- end)
- game:GetService'RunService'.RenderStepped:Connect(function()
- if not VREnabled then
- CurrentCF.Head *= CFrame.new(Directions.Right,0,-Directions.Forwards)
- CurrentCF.Head *= CFrame.new(-Directions.Left,0,Directions.Backwards)
- CurrentCF.Head = CFrame.new(CurrentCF.Head.Position) * getRotationCF(Cam.CFrame)
- end
- applyCFrames()
- end)
- ]],value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement