Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Simple setup:
- -- 1) Go to starter player, then starter character scripts
- -- 2) create a local script inside of it
- -- 3) paste the code underneath into it
- -- And you're done!
- local wall = nil
- local hrp = script.Parent:WaitForChild("HumanoidRootPart")
- local anim = script.Parent:WaitForChild("Humanoid"):LoadAnimation(script.Parent:WaitForChild("Animate").climb.ClimbAnim)
- local uis = game:GetService("UserInputService")
- game:GetService("RunService").Heartbeat:Connect(function()
- local raycastParams = RaycastParams.new()
- raycastParams.FilterDescendantsInstances = {script.Parent}
- local raycastResult = workspace:Raycast(script.Parent.LeftFoot.Position, hrp.CFrame.LookVector * 2.5, raycastParams)
- wall = raycastResult and raycastResult.Instance or nil
- local w = uis:IsKeyDown(Enum.KeyCode.W)
- local s = uis:IsKeyDown(Enum.KeyCode.S)
- local a = uis:IsKeyDown(Enum.KeyCode.A)
- local d = uis:IsKeyDown(Enum.KeyCode.D)
- if wall then -- on the wall
- if w then -- go up
- anim:AdjustSpeed(1)
- hrp.Velocity = Vector3.new(hrp.Velocity.X, 20, hrp.Velocity.Z)
- workspace.Gravity = 0
- if script.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Climbing then script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Climbing) end
- if not anim.IsPlaying then anim:Play() end
- elseif a then
- anim:AdjustSpeed(1)
- hrp.Velocity = Vector3.new(hrp.Velocity.X, 0, hrp.Velocity.Z)
- workspace.Gravity = 0
- if script.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Climbing then script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Climbing) end
- if not anim.IsPlaying then anim:Play() end
- elseif s then
- anim:AdjustSpeed(1)
- hrp.Velocity = Vector3.new(hrp.Velocity.X, -20, hrp.Velocity.Z)
- workspace.Gravity = 0
- if script.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Climbing then script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Climbing) end
- if not anim.IsPlaying then anim:Play() end
- elseif d then
- anim:AdjustSpeed(1)
- hrp.Velocity = Vector3.new(hrp.Velocity.X, 0, hrp.Velocity.Z)
- workspace.Gravity = 0
- if script.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Climbing then script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Climbing) end
- if not anim.IsPlaying then anim:Play() end
- elseif not w then -- pausing on the wall
- hrp.Velocity = Vector3.new(hrp.Velocity.X, 0, hrp.Velocity.Z)
- anim:AdjustSpeed(0)
- end
- else -- off the wall
- workspace.Gravity = 196.6
- anim:Stop()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement