C-H-4-0-S

Old Elderly Anim

Sep 27th, 2024
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. game.Players.LocalPlayer.Character:BreakJoints()
  2. game.Players.LocalPlayer.Character=nil
  3. Connection = game.Workspace.DescendantAdded:Connect(function(c)
  4. if c.Name == "Animate" then
  5. c.Disabled=true
  6. end
  7. end)
  8. repeat wait() until game.Players.LocalPlayer.Character
  9. Char = game.Players.LocalPlayer.Character
  10. Died = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:Connect(function()
  11. Connection:Disconnect()
  12. Died:Disconnect()
  13. end)
  14. wait(.1)
  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 = game.Players.LocalPlayer.Character
  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. local jumpMaxLimbVelocity = 0.75
  42.  
  43. -- functions
  44.  
  45. function onRunning(speed)
  46. if speed>0 then
  47. pose = "Running"
  48. else
  49. pose = "Standing"
  50. end
  51. end
  52.  
  53. function onDied()
  54. pose = "Dead"
  55. end
  56.  
  57. function onJumping()
  58. pose = "Jumping"
  59. end
  60.  
  61. function onClimbing()
  62. pose = "Climbing"
  63. end
  64.  
  65. function onGettingUp()
  66. pose = "GettingUp"
  67. end
  68.  
  69. function onFreeFall()
  70. pose = "FreeFall"
  71. end
  72.  
  73. function onFallingDown()
  74. pose = "FallingDown"
  75. end
  76.  
  77. function onSeated()
  78. pose = "Seated"
  79. end
  80.  
  81. function onPlatformStanding()
  82. pose = "PlatformStanding"
  83. end
  84.  
  85. function onSwimming(speed)
  86. if speed>0 then
  87. pose = "Running"
  88. else
  89. pose = "Standing"
  90. end
  91. end
  92.  
  93. function moveJump()
  94. RightShoulder.MaxVelocity = jumpMaxLimbVelocity
  95. LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
  96. RightShoulder:SetDesiredAngle(3.14)
  97. LeftShoulder:SetDesiredAngle(-3.14)
  98. RightHip:SetDesiredAngle(0)
  99. LeftHip:SetDesiredAngle(0)
  100. end
  101.  
  102.  
  103. -- same as jump for now
  104.  
  105. function moveFreeFall()
  106. RightShoulder.MaxVelocity = jumpMaxLimbVelocity
  107. LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
  108. RightShoulder:SetDesiredAngle(3.14)
  109. LeftShoulder:SetDesiredAngle(-3.14)
  110. RightHip:SetDesiredAngle(0)
  111. LeftHip:SetDesiredAngle(0)
  112. end
  113.  
  114. function moveSit()
  115. RightShoulder.MaxVelocity = 0.15
  116. LeftShoulder.MaxVelocity = 0.15
  117. RightShoulder:SetDesiredAngle(3.14 /2)
  118. LeftShoulder:SetDesiredAngle(-3.14 /2)
  119. RightHip:SetDesiredAngle(3.14 /2)
  120. LeftHip:SetDesiredAngle(-3.14 /2)
  121. end
  122.  
  123. function getTool()
  124. for _, kid in ipairs(Figure:GetChildren()) do
  125. if kid.className == "Tool" then return kid end
  126. end
  127. return nil
  128. end
  129.  
  130. function getToolAnim(tool)
  131. for _, c in ipairs(tool:GetChildren()) do
  132. if c.Name == "toolanim" and c.className == "StringValue" then
  133. return c
  134. end
  135. end
  136. return nil
  137. end
  138.  
  139. function animateTool()
  140.  
  141. if (toolAnim == "None") then
  142. RightShoulder:SetDesiredAngle(1.57)
  143. return
  144. end
  145.  
  146. if (toolAnim == "Slash") then
  147. RightShoulder.MaxVelocity = 0.5
  148. RightShoulder:SetDesiredAngle(0)
  149. return
  150. end
  151.  
  152. if (toolAnim == "Lunge") then
  153. RightShoulder.MaxVelocity = 0.5
  154. LeftShoulder.MaxVelocity = 0.5
  155. RightHip.MaxVelocity = 0.5
  156. LeftHip.MaxVelocity = 0.5
  157. RightShoulder:SetDesiredAngle(1.57)
  158. LeftShoulder:SetDesiredAngle(1.0)
  159. RightHip:SetDesiredAngle(1.57)
  160. LeftHip:SetDesiredAngle(1.0)
  161. return
  162. end
  163. end
  164.  
  165. function move(time)
  166. local amplitude
  167. local frequency
  168.  
  169. if (pose == "Jumping") then
  170. moveJump()
  171. return
  172. end
  173.  
  174. if (pose == "FreeFall") then
  175. moveFreeFall()
  176. return
  177. end
  178.  
  179. if (pose == "Seated") then
  180. moveSit()
  181. return
  182. end
  183.  
  184. local climbFudge = 0
  185.  
  186. if (pose == "Running") then
  187. if (RightShoulder.CurrentAngle > 1.5 or RightShoulder.CurrentAngle < -1.5) then
  188. RightShoulder.MaxVelocity = jumpMaxLimbVelocity
  189. else
  190. RightShoulder.MaxVelocity = 0.15
  191. end
  192. if (LeftShoulder.CurrentAngle > 1.5 or LeftShoulder.CurrentAngle < -1.5) then
  193. LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
  194. else
  195. LeftShoulder.MaxVelocity = 0.15
  196. end
  197. amplitude = 1
  198. frequency = 9
  199. elseif (pose == "Climbing") then
  200. RightShoulder.MaxVelocity = 0.5
  201. LeftShoulder.MaxVelocity = 0.5
  202. amplitude = 1
  203. frequency = 9
  204. climbFudge = 3.14
  205. else
  206. amplitude = 0.1
  207. frequency = 1
  208. end
  209.  
  210. desiredAngle = amplitude * math.sin(time*frequency)
  211.  
  212. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  213. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  214. RightHip:SetDesiredAngle(-desiredAngle)
  215. LeftHip:SetDesiredAngle(-desiredAngle)
  216.  
  217.  
  218. local tool = getTool()
  219.  
  220. if tool then
  221.  
  222. animStringValueObject = getToolAnim(tool)
  223.  
  224. if animStringValueObject then
  225. toolAnim = animStringValueObject.Value
  226. -- message recieved, delete StringValue
  227. animStringValueObject.Parent = nil
  228. toolAnimTime = time + .3
  229. end
  230.  
  231. if time > toolAnimTime then
  232. toolAnimTime = 0
  233. toolAnim = "None"
  234. end
  235.  
  236. animateTool()
  237.  
  238.  
  239. else
  240. toolAnim = "None"
  241. toolAnimTime = 0
  242. end
  243. end
  244.  
  245.  
  246. -- connect events
  247.  
  248. Humanoid.Died:connect(onDied)
  249. Humanoid.Running:connect(onRunning)
  250. Humanoid.Jumping:connect(onJumping)
  251. Humanoid.Climbing:connect(onClimbing)
  252. Humanoid.GettingUp:connect(onGettingUp)
  253. Humanoid.FreeFalling:connect(onFreeFall)
  254. Humanoid.FallingDown:connect(onFallingDown)
  255. Humanoid.Seated:connect(onSeated)
  256. Humanoid.PlatformStanding:connect(onPlatformStanding)
  257. Humanoid.Swimming:connect(onSwimming)
  258. -- main program
  259.  
  260. local runService = game:service("RunService");
  261.  
  262. while Figure.Parent~=nil do
  263. local _, time = wait(0.1)
  264. move(time)
  265. end
Add Comment
Please, Sign In to add comment