Advertisement
SlappyDappyCrappy

movementos

Jul 7th, 2016
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. game.Players.LocalPlayer.CameraMode = "Classic"
  2.         pls = game:GetService'Players'
  3.         rs = game:GetService'RunService'
  4.         uinps = game:GetService'UserInputService'
  5.         lp = pls.LocalPlayer
  6.         mouse = lp:GetMouse()
  7.         c = lp.Character
  8.         human = c.Humanoid
  9.         human.MaxHealth = math.huge
  10.         soundVol = 0
  11.         wait()
  12.         human.Health = math.huge
  13.         c.Health:Destroy()
  14. local shieldlyboi = Instance.new("ForceField", c)
  15. shieldlyboi.Visible = false
  16. local s = game.Players.LocalPlayer.Character local Torso = s:WaitForChild("Torso")
  17. local CF, V3, Ang, pi, sqrt = CFrame.new, Vector3.new, CFrame.Angles, math.pi, math.sqrt
  18. s.Humanoid.WalkSpeed = 8
  19. local Body = s.HumanoidRootPart
  20. local Head = s.Head
  21. local TorsoWeld = Body.RootJoint
  22. local HeadWeld = s.Torso.Neck
  23. local Mouse = game.Players.LocalPlayer:GetMouse()
  24. local Camera = game.Workspace.CurrentCamera
  25. local c = true
  26. local Crouch = 0
  27. local Crouching = false
  28. local SprintAmount = 0
  29. local Sprinting = false
  30. local Lean = 0
  31. local Humanoid = s.Humanoid
  32. function minmax(l, x, u)
  33.     return math.max(l, math.min(x, u))
  34. end
  35. function MakeWeld(Part0, Part1)
  36.     local w = Instance.new("Weld", Part0)
  37.     w.Part0, w.Part1 = Part0, Part1
  38.     return w
  39. end
  40. function JointAction(Weld, AttachPoint, Point)
  41.     local Part0Down = Weld.Part0.CFrame * AttachPoint * Ang(-pi/2, 0, 0)
  42.     local ApplicDist = math.min(2, (Point - Part0Down.p).magnitude)
  43.     local JointCFrame = Part0Down * CF(V3(), Part0Down:inverse() * Point)
  44.     local JointLine = Weld.Part0.CFrame:inverse() * JointCFrame * Ang(pi/2, 0, 0)
  45.     Weld.C0 = JointLine * CF(0, -ApplicDist / 2, -sqrt(1 - ApplicDist^2 / 4))
  46.      Weld.C1 = Ang(math.acos(ApplicDist / 2), 0, 0)
  47. end
  48. function Smooth(Start, End, x)
  49.     return (3*x^2-2*x^3)*(End - Start) + Start
  50. end
  51. Body.CanCollide = false
  52. TorsoWeld.C1 = CF(0, -1, 0)
  53. HeadWeld.C1 = CF(0, -0.5, 0)
  54. function KeyPressed(Key)
  55.     if Key == "c" then
  56.         if not Crouching then
  57.         Sprinting = false
  58.         Crouching = true
  59.         local WalkSpeedStart = Humanoid.WalkSpeed
  60.         local CrouchStart = Crouch
  61.         local SprintAmountStart = SprintAmount
  62.         for i = 0, 1, 1/10 do
  63.             wait(1/30)
  64.             Crouch = Smooth(CrouchStart, -1, i)
  65.             SprintAmount = Smooth(SprintAmountStart, 0, i)
  66.             Humanoid.WalkSpeed = Smooth(WalkSpeedStart, 4, i)
  67.         end
  68.         else
  69.         Sprinting = false
  70.         Crouching = false
  71.         local WalkSpeedStart = Humanoid.WalkSpeed
  72.         local CrouchStart = Crouch
  73.         local SprintAmountStart = SprintAmount
  74.         for i = 0, 1, 1/10 do
  75.             wait(1/30)
  76.             Crouch = Smooth(CrouchStart, 0, i)
  77.             SprintAmount = Smooth(SprintAmountStart, 0, i)
  78.             Humanoid.WalkSpeed = Smooth(WalkSpeedStart, 8, i)
  79.         end
  80.         end
  81.     elseif Key == "0" then
  82.         Sprinting = true
  83.         Crouching = false
  84.         local WalkSpeedStart = Humanoid.WalkSpeed
  85.         local CrouchStart = Crouch
  86.         local SprintAmountStart = SprintAmount
  87.         for i = 0, 1, 1/15 do
  88.             wait(1/30)
  89.             Crouch = Smooth(CrouchStart, 0, i)
  90.             SprintAmount = Smooth(SprintAmountStart, 1, i)
  91.             Humanoid.WalkSpeed = Smooth(WalkSpeedStart, 22, i)
  92.         end
  93.     elseif Key == "q" then
  94.         local Start = Lean
  95.         for i = 0, 1, 1/10 do
  96.             wait(1/30)
  97.             Lean = Smooth(Start, 1, i)
  98.         end
  99.     elseif Key == "e" then
  100.         local Start = Lean
  101.         for i = 0, 1, 1/10 do
  102.             wait(1/30)
  103.             Lean = Smooth(Start, -1, i)
  104.         end
  105.     elseif Key == "p" then
  106.         c = not c
  107.         if c then
  108.             game.Players.LocalPlayer.CameraMode = "LockFirstPerson"
  109.         else
  110.             game.Players.LocalPlayer.CameraMode = "Classic"
  111.         end
  112.     end
  113. end
  114. function KeyDepressed(Key)
  115.     if Key == "0" then
  116.         Sprinting = false
  117.         local WalkSpeedStart = Humanoid.WalkSpeed
  118.         local SprintAmountStart = SprintAmount
  119.         for i = 0, 1, 1/15 do
  120.             wait(1/30)
  121.             SprintAmount = Smooth(SprintAmountStart, 0, i)
  122.             Humanoid.WalkSpeed = Smooth(WalkSpeedStart, 8, i)
  123.         end
  124.     elseif Key == "q" or Key == "e" then
  125.         local Start = Lean
  126.         for i = 0, 1, 1/10 do
  127.             wait(1/30)
  128.             Lean = Smooth(Start, 0, i)
  129.         end
  130.     end
  131. end
  132. Mouse.KeyDown:connect(KeyPressed)
  133. Mouse.KeyUp:connect(KeyDepressed)
  134. local LegWeld1, LegWeld2 = MakeWeld(Body, s["Right Leg"]), MakeWeld(Body, s["Left Leg"])
  135. local i = 0
  136. local SmoothVelocity, Raise = Vector3.new(1, 1, 1), 0
  137. local Sprint = 1
  138. while wait(1/30) do
  139.     if not Humanoid.PlatformStand and not Humanoid.Sit then
  140.         LegWeld1.Parent = Body
  141.         LegWeld2.Parent = Body
  142.         if Body.Velocity.magnitude >= 1 then SmoothVelocity = (SmoothVelocity * 3 + Body.Velocity) / 4 Raise = Raise * 7/8 + 1/8 Sprint = (Body.Velocity.magnitude / 8 + 0.0001)^(3/4) else Raise = Raise * 7/8 end
  143.         local ti = (Body.CFrame - Body.CFrame.p):inverse()
  144.         i = i + ((ti * Torso.Velocity) * V3(1, 0, 1)).magnitude/60/Sprint
  145.         JointAction(LegWeld1, CF(0.5, Crouch * 2/3 - 1, 0), (Body.CFrame * CF(0.5, Sprint * math.min(math.max(-0.1, Raise * math.cos(pi*i) / 3), 1/4) - 2.9, 0) + SmoothVelocity.unit * Sprint * math.sin(pi*i)).p)
  146.         JointAction(LegWeld2, CF(-0.5, Crouch * 2/3 - 1, 0), (Body.CFrame * CF(-0.5, Sprint * math.min(math.max(-0.1, Raise * -math.cos(pi*i) / 3), 1/4) - 2.9, 0) + SmoothVelocity.unit * Sprint * -math.sin(pi*i)).p)
  147.         TorsoWeld.C0 = CF(0, Crouch - 1, 0) * Ang(Crouch*pi/8 + SprintAmount*pi*(ti*SmoothVelocity).unit.z/8, (Crouch - SprintAmount)*math.cos(pi*i)*pi / 16, -SprintAmount*pi*(ti*SmoothVelocity).unit.x/8 + Lean*pi/8)
  148.         HeadWeld.C0 = CF(0, 1, 0) * Ang(-Crouch*pi/8 - SprintAmount*pi*(ti*SmoothVelocity).unit.z/8, (SprintAmount - Crouch)*math.cos(pi*i)*pi / 16, SprintAmount*pi*(ti*SmoothVelocity).unit.x/8 + Lean*pi/8)
  149.         if (Camera.CoordinateFrame.p - Head.CFrame.p).magnitude <= 3 then
  150.             CameraLV = (Body.CFrame:inverse() * Camera.CoordinateFrame).lookVector
  151.             Parse = (CameraLV + Vector3.new(0, 0, -1)).unit
  152.             Parsex, Parsey, Parsez = CF(V3(), Parse):toEulerAnglesXYZ()
  153.             TorsoWeld.C0 = TorsoWeld.C0 * Ang(minmax(-pi/6, Parsex, pi/6) / (1 + SprintAmount), minmax(-pi/6, Parsey, pi/6) / (1 + SprintAmount), 0)
  154.             HeadWeld.C0 = HeadWeld.C0 * Ang(minmax(-pi/3, Parsex, pi/3) / (1 + SprintAmount), minmax(-pi/3, Parsey, pi/3) / (1 + SprintAmount), 0)
  155. --            TorsoWeld.C0 = TorsoWeld.C0 * Ang(Parsex, Parsey, 0)
  156. --            HeadWeld.C0 = HeadWeld.C0 * Ang(Parsex, Parsey, 0)
  157.         end
  158.     else
  159.         TorsoWeld.C0 = CF(0, -1, 0)
  160.         HeadWeld.C0 = CF(0, 1, 0)
  161.         LegWeld1.Parent = nil
  162.         LegWeld2.Parent = nil
  163.     end
  164. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement