mewishmeww

Parkour

May 22nd, 2023 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.29 KB | None | 0 0
  1. script.Parent = game.Workspace:FindFirstChild("calternitive")
  2. local Character = script.Parent
  3. local T = Character.Torso
  4. local Humanoid = Character:FindFirstChildOfClass'Humanoid'
  5. local RootPart = Character:WaitForChild'HumanoidRootPart'
  6. local RootJoint = RootPart:WaitForChild'RootJoint'
  7. local RootC0 = RootJoint.C0
  8. local walking = false
  9. Humanoid.WalkSpeed = 30
  10. local MaxTiltAngle = 1 * Humanoid.WalkSpeed
  11. local TweenService = game:GetService("TweenService")
  12. local landing = false
  13. local jumping = false
  14. local slidetool = Instance.new("Tool")
  15. slidetool.Parent = game.Players:FindFirstChild(script.Parent.Name).Backpack
  16. slidetool.RequiresHandle = false
  17. slidetool.Name = "Slide"
  18. local sliding = false
  19.  
  20. script.Parent:WaitForChild("Animate",3000000):Destroy()
  21. local animspeed = 0.2
  22.  
  23. local wall = nil
  24.  
  25. local hrp = script.Parent:WaitForChild("HumanoidRootPart")
  26.  
  27. local wall
  28. game:GetService("RunService").Heartbeat:Connect(function()
  29.     local raycastParams = RaycastParams.new()
  30.     raycastParams.FilterDescendantsInstances = {script.Parent}
  31.     local raycastResult = workspace:Raycast(script.Parent["Left Leg"].Position, hrp.CFrame.LookVector * 1.85, raycastParams)
  32.     wall = raycastResult and raycastResult.Instance or nil
  33.     if wall and (script.Parent.Humanoid.MoveDirection.Magnitude) > 0.01 then
  34.         hrp.Velocity = Vector3.new(hrp.Velocity.X, script.Parent.Humanoid.WalkSpeed, hrp.Velocity.Z)
  35.         if script.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Climbing then script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Climbing) end
  36.     end
  37. end)
  38.  
  39.  
  40. function RunAnim()
  41.     if walking and not landing and not jumping then
  42.         TweenService:Create(T.Neck,TweenInfo.new(animspeed,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 1, 0, -1, -7.57103464e-08, -4.37113918e-08, 0, -0.50000006, 0.866025388, -8.74227766e-08, 0.866025388, 0.50000006)}):Play()
  43.         TweenService:Create(T["Right Hip"],TweenInfo.new(animspeed,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, -1, 0, -2.18556924e-08, 3.78551732e-08, 1, 0.866025448, 0.49999997, 0, -0.49999997, 0.866025448, -4.37113883e-08)}):Play()
  44.         TweenService:Create(T["Right Shoulder"],TweenInfo.new(animspeed,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, 0.5, 0, -3.09086197e-08, -3.09086197e-08, 1, -0.707106769, 0.707106769, 0, -0.707106769, -0.707106769, -4.37113883e-08)}):Play()
  45.         TweenService:Create(T["Left Hip"],TweenInfo.new(animspeed,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, -1, 0, -3.09086197e-08, 3.09086197e-08, -1, 0.707106769, 0.707106769, 0, 0.707106769, -0.707106769, -4.37113883e-08)}):Play()
  46.         TweenService:Create(T["Left Shoulder"],TweenInfo.new(animspeed,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0.5, 0, -3.09086197e-08, -3.09086197e-08, -1, -0.707106769, 0.707106769, 0, 0.707106769, 0.707106769, -4.37113883e-08)}):Play()
  47.     else
  48.         return
  49.     end
  50.     wait(animspeed)
  51.     if walking and not landing and not jumping then
  52.         TweenService:Create(T.Neck,TweenInfo.new(animspeed,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 1, 0, -1, -7.57103464e-08, -4.37113918e-08, 0, -0.50000006, 0.866025388, -8.74227766e-08, 0.866025388, 0.50000006)}):Play()
  53.         TweenService:Create(T["Right Hip"],TweenInfo.new(animspeed,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, -1, 0, -2.18556924e-08, -3.78551732e-08, 1, -0.866025448, 0.49999997, 0, -0.49999997, -0.866025448, -4.37113883e-08)}):Play()
  54.         TweenService:Create(T["Right Shoulder"],TweenInfo.new(animspeed,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, 0.5, 0, -2.18556924e-08, 3.78551732e-08, 1, 0.866025448, 0.49999997, 0, -0.49999997, 0.866025448, -4.37113883e-08)}):Play()
  55.         TweenService:Create(T["Left Hip"],TweenInfo.new(animspeed,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, -1, -0.5, -2.18556924e-08, -3.78551732e-08, -1, -0.866025448, 0.49999997, 0, 0.49999997, 0.866025448, -4.37113883e-08)}):Play()
  56.         TweenService:Create(T["Left Shoulder"],TweenInfo.new(animspeed,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0.5, 0, -2.18556924e-08, 3.78551732e-08, -1, 0.866025448, 0.49999997, 0, 0.49999997, -0.866025448, -4.37113883e-08)}):Play()
  57.     else
  58.         return
  59.     end
  60.     wait(animspeed)
  61. end
  62.  
  63. function Idle()
  64.     if not walking and not landing and not jumping then
  65.         TweenService:Create(T.Neck,TweenInfo.new(0.1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)}):Play()
  66.         TweenService:Create(T["Right Hip"],TweenInfo.new(0.1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)}):Play()
  67.         TweenService:Create(T["Right Shoulder"],TweenInfo.new(0.1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, -0.5, 0, -0.241844609, 0.939692676, 0.241844684, 0.707106829, -3.09086197e-08, 0.707106769, 0.664463043, 0.342019975, -0.664463103)}):Play()
  68.         TweenService:Create(T["Left Hip"],TweenInfo.new(0.1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, -1, 0, 0.173648104, 0.0858316571, -0.981060326, 0, 0.99619472, 0.0871557444, 0.984807789, -0.0151344296, 0.172987327)}):Play()
  69.         TweenService:Create(T["Left Shoulder"],TweenInfo.new(0.1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, -0.5, 0, -0.241844609, -0.939692676, -0.241844684, -0.707106829, -3.09086197e-08, 0.707106769, -0.664463043, 0.342019975, -0.664463103)}):Play()
  70.     else
  71.         return
  72.     end
  73. end
  74.  
  75. function Land()
  76.     landing = true
  77.     TweenService:Create(RootJoint,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, -1, 0, -1, -8.74227766e-08, -3.82137093e-15, 0, -4.37113883e-08, 1, -8.74227766e-08, 1, 4.37113883e-08)}):Play()
  78.     TweenService:Create(T.Neck,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 1, 0, -1, -6.18172393e-08, 6.18172393e-08, 0, 0.707106769, 0.707106769, -8.74227766e-08, 0.707106769, -0.70710676)}):Play()
  79.     TweenService:Create(T["Right Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, 0, -0.5, 0.49999997, 0, 0.866025448, 0, 1, 0, -0.866025448, 0, 0.49999997)}):Play()
  80.     TweenService:Create(T["Right Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, 0.5, 0, 0.49999994, -0.5, 0.707106769, -0.49999997, 0.49999997, 0.707106769, -0.707106769, -0.707106769, -3.09086197e-08)}):Play()
  81.     TweenService:Create(T["Left Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-0.200000003, 0, -0.5, 0.707106769, 0, 0.707106769, 0, 1, 0, -0.707106769, 0, 0.707106769)}):Play()
  82.     TweenService:Create(T["Left Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0.5, 0, 0.49999994, 0.5, -0.707106769, 0.49999997, 0.49999997, 0.707106769, 0.707106769, -0.707106769, -3.09086197e-08)}):Play()
  83.     wait(0.3)
  84.     TweenService:Create(RootJoint,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 0, 0, -1, -1.50995803e-07, -6.60023616e-15, 0, -4.37113883e-08, 1, -1.50995803e-07, 1, 4.37113883e-08)}):Play()
  85.     TweenService:Create(T.Neck,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 1, 0, -1, 7.57103464e-08, -4.37113847e-08, 0, 0.49999997, 0.866025448, 8.74227766e-08, 0.866025448, -0.49999997)}):Play()
  86.     TweenService:Create(T["Right Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0.5, -1, -0.100000001, 1, 0, 0, 0, 1, 0, 0, 0, 1)}):Play()
  87.     TweenService:Create(T["Right Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, 0.5, 0, -4.37113883e-08, -0.342020154, 0.939692616, 0, 0.939692616, 0.342020154, -1, 1.49501762e-08, -4.10752676e-08)}):Play()
  88.     TweenService:Create(T["Left Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-0.5, -1, -0.100000001, 1, 0, 0, 0, 1, 0, 0, 0, 1)}):Play()
  89.     TweenService:Create(T["Left Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0.5, 0, -4.37113883e-08, 0.342020154, -0.939692616, 0, 0.939692616, 0.342020154, 1, 1.49501762e-08, -4.10752676e-08)}):Play()
  90.     wait(0.3)
  91.     landing = false
  92. end
  93.  
  94. function jump()
  95.     jumping = true
  96.     TweenService:Create(RootJoint,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 0, 0, -1, 8.60946301e-08, -1.51807988e-08, 0, 0.173648104, 0.984807789, 8.74227766e-08, 0.984807789, -0.173648104)}):Play()
  97.     TweenService:Create(T.Neck,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 1, 0, -1, 8.74227766e-08, 0, -4.37113847e-08, -0.49999997, 0.866025448, 7.57103464e-08, 0.866025448, 0.49999997)}):Play()
  98.     TweenService:Create(T["Right Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, -1, 0, -1.49501709e-08, -4.10752712e-08, 1, -0.939692676, 0.342020035, 0, -0.342020035, -0.939692676, -4.37113883e-08)}):Play()
  99.     TweenService:Create(T["Right Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, 0.5, 0, -0.5, -0.49999994, 0.707106769, 0.49999997, 0.49999997, 0.707106769, -0.707106769, 0.707106769, -3.09086197e-08)}):Play()
  100.     TweenService:Create(T["Left Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0, -1, -3.34848664e-08, -2.80971406e-08, -1, -0.642787635, 0.766044438, 0, 0.766044438, 0.642787635, -4.37113883e-08)}):Play()
  101.     TweenService:Create(T["Left Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0.5, 0, -0.5, 0.49999994, -0.707106769, -0.49999997, 0.49999997, 0.707106769, 0.707106769, 0.707106769, -3.09086197e-08)}):Play()
  102.     wait(0.3)
  103.     jumping = false
  104. end
  105.  
  106. function climb()
  107.     TweenService:Create(RootJoint,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 0, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)}):Play()
  108.     TweenService:Create(T.Neck,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 1, 0, -1, 6.18172393e-08, 6.18172393e-08, 0, -0.707106769, 0.707106769, 8.74227766e-08, 0.707106769, 0.707106769)}):Play()
  109.     TweenService:Create(T["Right Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, 0, -0.219999999, -4.37113883e-08, 0, 1, 0, 1, 0, -1, 0, -4.37113883e-08)}):Play()
  110.     TweenService:Create(T["Right Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)}):Play()
  111.     TweenService:Create(T["Left Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)}):Play()
  112.     TweenService:Create(T["Left Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0.5, 0, 4.37113883e-08, 3.82137093e-15, -1, 8.74227766e-08, -1, 0, -1, -8.74227766e-08, -4.37113883e-08)}):Play()
  113.     wait(animspeed)
  114.     TweenService:Create(RootJoint,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 0, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)}):Play()
  115.     TweenService:Create(T.Neck,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 1, 0, -1, 6.18172393e-08, 6.18172393e-08, 0, -0.707106769, 0.707106769, 8.74227766e-08, 0.707106769, 0.707106769)}):Play()
  116.     TweenService:Create(T["Right Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, -1, 0, -4.37113883e-08, 0, 1, 0, 1, 0, -1, 0, -4.37113883e-08)}):Play()
  117.     TweenService:Create(T["Right Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, 0.5, 0, 4.37113883e-08, -3.82137093e-15, 1, -8.74227766e-08, -1, 0, 1, -8.74227766e-08, -4.37113883e-08)}):Play()
  118.     TweenService:Create(T["Left Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0, -0.219999999, -4.37113883e-08, 0, -1, 0, 1, 0, 1, 0, -4.37113883e-08)}):Play()
  119.     TweenService:Create(T["Left Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0.5, 0, -4.30473115e-08, -7.59040386e-09, -1, -0.173648193, 0.98480773, 0, 0.98480773, 0.173648193, -4.37113883e-08)}):Play()
  120.     wait(animspeed)
  121. end
  122.  
  123. function slide(Timer)
  124.     sliding = true
  125.     TweenService:Create(RootJoint,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, -2, 0, -1, 1.50995803e-07, 0, -5.1643589e-08, -0.342020035, 0.939692676, 1.41889643e-07, 0.939692676, 0.342020035)}):Play()
  126.     TweenService:Create(T.Neck,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(0, 1, 0, -1, 8.21505424e-08, -2.99003418e-08, 0, 0.342020035, 0.939692676, 8.74227766e-08, 0.939692676, -0.342020035)}):Play()
  127.     TweenService:Create(T["Right Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, -1, 0, -1.49501709e-08, 4.10752712e-08, 1, 0.939692676, 0.342020035, 0, -0.342020035, 0.939692676, -4.37113883e-08)}):Play()
  128.     TweenService:Create(T["Right Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(1, 0.5, 0, -1.49501709e-08, 4.10752712e-08, 1, 0.939692676, 0.342020035, 0, -0.342020035, 0.939692676, -4.37113883e-08)}):Play()
  129.     TweenService:Create(T["Left Hip"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0, -0.5, -4.37113883e-08, 0, -1, 0, 1, 0, 1, 0, -4.37113883e-08)}):Play()
  130.     TweenService:Create(T["Left Shoulder"],TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{C0 = CFrame.new(-1, 0.5, 0, -3.78551732e-08, 2.18556941e-08, -1, 0.5, 0.866025388, 0, 0.866025388, -0.5, -4.37113883e-08)}):Play()
  131.     wait(Timer)
  132.     sliding = false
  133. end
  134.  
  135. Humanoid.Jumping:Connect(function()
  136.     if not wall and not sliding then
  137.         jump()
  138.     end
  139. end)
  140.  
  141. local Tilt = CFrame.new()
  142. game:GetService("RunService").Heartbeat:Connect(function(Delta)
  143.     if not landing and not jumping and not wall and not sliding then
  144.         local MoveDirection = RootPart.CFrame:VectorToObjectSpace(Humanoid.MoveDirection)
  145.         Tilt = Tilt:Lerp(CFrame.Angles(math.rad(-MoveDirection.Z) * MaxTiltAngle, math.rad(-MoveDirection.X) * MaxTiltAngle, 0), 0.2 ^ (1 / (Delta * 60)))
  146.         RootJoint.C0 = RootC0 * Tilt
  147.     end
  148. end)
  149.  
  150. game:GetService("RunService").Heartbeat:Connect(function(Delta)
  151.     if Humanoid.MoveDirection.Magnitude>0.01 then
  152.         walking = true
  153.     else
  154.         walking = false
  155.     end
  156. end)
  157.  
  158. game:GetService("RunService").Heartbeat:Connect(function()
  159.     if script.Parent.Torso.Velocity.Y > 10 and not landing and not wall and not sliding then -- Are they in the air?
  160.         repeat game:GetService("RunService").Heartbeat:Wait() until script.Parent.Torso.Velocity.Y <= 0 -- When do they land?
  161.         Land()
  162.     end
  163. end)
  164.  
  165. slidetool.Equipped:Connect(function()
  166.     if not sliding then
  167.         local slider = Instance.new("BodyVelocity")
  168.         slider.MaxForce = Vector3.new(1,0,1) * 30000
  169.         slider.Velocity = script.Parent.HumanoidRootPart.CFrame.lookVector * 100
  170.         slider.Parent = script.Parent.HumanoidRootPart
  171.         slide(1)
  172.         slider:Destroy()
  173.     end
  174. end)
  175.  
  176. while wait() do
  177.     if walking and not wall and not sliding then
  178.         RunAnim()
  179.     else
  180.         if not sliding then
  181.             Idle()
  182.         end
  183.     end
  184.     if wall and not sliding then
  185.         climb()
  186.     end
  187. end
Advertisement
Add Comment
Please, Sign In to add comment