Advertisement
Lollddsf

2007

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