Advertisement
Aleksandrs5435

old jump

Dec 14th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. --ScriptGuider
  2.  
  3. function new(play)
  4. play.CharacterAdded:connect(function(char)
  5. char:WaitForChild("Animate"):Destroy()
  6. local Script=script.Animation:clone()
  7. Script.Parent=char
  8. Script.Disabled=false
  9. end)
  10. end
  11.  
  12. game.Players.PlayerAdded:connect(new)
  13.  
  14.  
  15. function waitForChild(parent, childName)
  16. local child = parent:findFirstChild(childName)
  17. if child then return child end
  18. while true do
  19. child = parent.ChildAdded:wait()
  20. if child.Name==childName then return child end
  21. end
  22. end
  23.  
  24. -- ANIMATION
  25.  
  26. -- declarations
  27.  
  28. local Figure = script.Parent
  29. local Torso = waitForChild(Figure, "Torso")
  30. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  31. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  32. local RightHip = waitForChild(Torso, "Right Hip")
  33. local LeftHip = waitForChild(Torso, "Left Hip")
  34. local Neck = waitForChild(Torso, "Neck")
  35. local Humanoid = waitForChild(Figure, "Humanoid")
  36. local pose = "Standing"
  37.  
  38. local toolAnim = "None"
  39. local toolAnimTime = 0
  40.  
  41. -- functions
  42.  
  43. function onRunning(speed)
  44. if speed>0 then
  45. pose = "Running"
  46. else
  47. pose = "Standing"
  48. end
  49. end
  50.  
  51. function onDied()
  52. pose = "Dead"
  53. end
  54.  
  55. function onJumping()
  56. pose = "Jumping"
  57. end
  58.  
  59. function onClimbing()
  60. pose = "Climbing"
  61. end
  62.  
  63. function onGettingUp()
  64. pose = "GettingUp"
  65. end
  66.  
  67. function onFreeFall()
  68. pose = "FreeFall"
  69. end
  70.  
  71. function onFallingDown()
  72. pose = "FallingDown"
  73. end
  74.  
  75. function onSeated()
  76. pose = "Seated"
  77. end
  78.  
  79. function onPlatformStanding()
  80. pose = "PlatformStanding"
  81. end
  82.  
  83. function moveJump()
  84. RightShoulder.MaxVelocity = 0.5
  85. LeftShoulder.MaxVelocity = 0.5
  86. RightShoulder.DesiredAngle = 3.14
  87. LeftShoulder.DesiredAngle = -3.14
  88. RightHip.DesiredAngle = 0
  89. LeftHip.DesiredAngle = 0
  90. end
  91.  
  92.  
  93. -- same as jump for now
  94.  
  95. function moveFreeFall()
  96. RightShoulder.MaxVelocity = 0.5
  97. LeftShoulder.MaxVelocity = 0.5
  98. RightShoulder.DesiredAngle = 3.14
  99. LeftShoulder.DesiredAngle = -3.14
  100. RightHip.DesiredAngle = 0
  101. LeftHip.DesiredAngle = 0
  102. end
  103.  
  104. function moveSit()
  105. RightShoulder.MaxVelocity = 0.15
  106. LeftShoulder.MaxVelocity = 0.15
  107. RightShoulder.DesiredAngle = 3.14 /2
  108. LeftShoulder.DesiredAngle = -3.14 /2
  109. RightHip.DesiredAngle = 3.14 /2
  110. LeftHip.DesiredAngle = -3.14 /2
  111. end
  112.  
  113. function getTool()
  114. for _, kid in ipairs(Figure:GetChildren()) do
  115. if kid.className == "Tool" then return kid end
  116. end
  117. return nil
  118. end
  119.  
  120. function getToolAnim(tool)
  121. for _, c in ipairs(tool:GetChildren()) do
  122. if c.Name == "toolanim" and c.className == "StringValue" then
  123. return c
  124. end
  125. end
  126. return nil
  127. end
  128.  
  129. function animateTool()
  130.  
  131. if (toolAnim == "None") then
  132. RightShoulder.DesiredAngle = 1.57
  133. return
  134. end
  135.  
  136. if (toolAnim == "Slash") then
  137. RightShoulder.MaxVelocity = 0.5
  138. RightShoulder.DesiredAngle = 0
  139. return
  140. end
  141.  
  142. if (toolAnim == "Lunge") then
  143. RightShoulder.MaxVelocity = 0.5
  144. LeftShoulder.MaxVelocity = 0.5
  145. RightHip.MaxVelocity = 0.5
  146. LeftHip.MaxVelocity = 0.5
  147. RightShoulder.DesiredAngle = 1.57
  148. LeftShoulder.DesiredAngle = 1.0
  149. RightHip.DesiredAngle = 1.57
  150. LeftHip.DesiredAngle = 1.0
  151. return
  152. end
  153. end
  154.  
  155. function move(time)
  156. local amplitude
  157. local frequency
  158.  
  159. if (pose == "Jumping") then
  160. moveJump()
  161. return
  162. end
  163.  
  164. if (pose == "FreeFall") then
  165. moveFreeFall()
  166. return
  167. end
  168.  
  169. if (pose == "Seated") then
  170. moveSit()
  171. return
  172. end
  173.  
  174. local climbFudge = 0
  175.  
  176. if (pose == "Running") then
  177. RightShoulder.MaxVelocity = 0.15
  178. LeftShoulder.MaxVelocity = 0.15
  179. amplitude = 1
  180. frequency = 9
  181. elseif (pose == "Climbing") then
  182. RightShoulder.MaxVelocity = 0.5
  183. LeftShoulder.MaxVelocity = 0.5
  184. amplitude = 1
  185. frequency = 9
  186. climbFudge = 3.14
  187. else
  188. amplitude = 0.1
  189. frequency = 1
  190. end
  191.  
  192. desiredAngle = amplitude * math.sin(time*frequency)
  193.  
  194. RightShoulder.DesiredAngle = desiredAngle + climbFudge
  195. LeftShoulder.DesiredAngle = desiredAngle - climbFudge
  196. RightHip.DesiredAngle = -desiredAngle
  197. LeftHip.DesiredAngle = -desiredAngle
  198.  
  199.  
  200. local tool = getTool()
  201.  
  202. if tool then
  203.  
  204. animStringValueObject = getToolAnim(tool)
  205.  
  206. if animStringValueObject then
  207. toolAnim = animStringValueObject.Value
  208. -- message recieved, delete StringValue
  209. animStringValueObject.Parent = nil
  210. toolAnimTime = time + .3
  211. end
  212.  
  213. if time > toolAnimTime then
  214. toolAnimTime = 0
  215. toolAnim = "None"
  216. end
  217.  
  218. animateTool()
  219.  
  220.  
  221. else
  222. toolAnim = "None"
  223. toolAnimTime = 0
  224. end
  225. end
  226.  
  227.  
  228. -- connect events
  229.  
  230. Humanoid.Died:connect(onDied)
  231. Humanoid.Running:connect(onRunning)
  232. Humanoid.Jumping:connect(onJumping)
  233. Humanoid.Climbing:connect(onClimbing)
  234. Humanoid.GettingUp:connect(onGettingUp)
  235. Humanoid.FreeFalling:connect(onFreeFall)
  236. Humanoid.FallingDown:connect(onFallingDown)
  237. Humanoid.Seated:connect(onSeated)
  238. Humanoid.PlatformStanding:connect(onPlatformStanding)
  239.  
  240. -- main program
  241.  
  242. local runService = game:service("RunService");
  243.  
  244. while Figure.Parent~=nil do
  245. local _, time = wait(0.1)
  246. move(time)
  247. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement