R15 to R8

Download Raw Clone


  1. game:GetObjects("rbxassetid://1561389244")[1].Parent=game.Workspace.Terrain
  2. local c = game.Workspace.Terrain:FindFirstChildOfClass("Model"):Clone()
  3. c.Parent = game.Workspace
  4. c:MoveTo(game.Players.LocalPlayer.Character.HumanoidRootPart.Position)
  5. game.Workspace.Terrain:FindFirstChildOfClass("Model"):remove()
  6. c.Name = game.Players.LocalPlayer.Name
  7. game.Players.LocalPlayer.Character = c
  8. game.Workspace.CurrentCamera.CameraSubject = c:FindFirstChildOfClass("Humanoid")
  9. local Figure = game.Players.LocalPlayer.Character
  10. local Torso = Figure:WaitForChild("Torso")
  11. local RightShoulder = Torso:WaitForChild("Right Shoulder")
  12. local LeftShoulder = Torso:WaitForChild("Left Shoulder")
  13. local RightHip = Torso:WaitForChild("Right Hip")
  14. local LeftHip = Torso:WaitForChild("Left Hip")
  15. local Neck = Torso:WaitForChild("Neck")
  16. local Humanoid = Figure:WaitForChild("Humanoid")
  17. local pose = "Standing"
  18. local currentAnim = ""
  19. local currentAnimInstance = nil
  20. local currentAnimTrack = nil
  21. local currentAnimKeyframeHandler = nil
  22. local currentAnimSpeed = 1.0
  23. local animTable = {}
  24. local animNames = {
  25. idle = {
  26. { id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
  27. { id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
  28. },
  29. walk = {
  30. { id = "http://www.roblox.com/asset/?id=180426354", weight = 10 }
  31. },
  32. run = {
  33. { id = "run.xml", weight = 10 }
  34. },
  35. jump = {
  36. { id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
  37. },
  38. fall = {
  39. { id = "http://www.roblox.com/asset/?id=180436148", weight = 10 }
  40. },
  41. climb = {
  42. { id = "http://www.roblox.com/asset/?id=180436334", weight = 10 }
  43. },
  44. sit = {
  45. { id = "http://www.roblox.com/asset/?id=178130996", weight = 10 }
  46. },
  47. toolnone = {
  48. { id = "http://www.roblox.com/asset/?id=182393478", weight = 10 }
  49. },
  50. toolslash = {
  51. { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  52. -- { id = "slash.xml", weight = 10 }
  53. },
  54. toollunge = {
  55. { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  56. },
  57. wave = {
  58. { id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
  59. },
  60. point = {
  61. { id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
  62. },
  63. dance1 = {
  64. { id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
  65. { id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
  66. { id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
  67. },
  68. dance2 = {
  69. { id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
  70. { id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
  71. { id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
  72. },
  73. dance3 = {
  74. { id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
  75. { id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
  76. { id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
  77. },
  78. laugh = {
  79. { id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
  80. },
  81. cheer = {
  82. { id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
  83. },
  84. }
  85. local dances = {"dance1", "dance2", "dance3"}
  86. -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
  87. local emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
  88. function configureAnimationSet(name, fileList)
  89. if (animTable[name] ~= nil) then
  90. for _, connection in pairs(animTable[name].connections) do
  91. connection:disconnect()
  92. end
  93. end
  94. animTable[name] = {}
  95. animTable[name].count = 0
  96. animTable[name].totalWeight = 0
  97. animTable[name].connections = {}
  98. -- check for config values
  99. local config = game.Players.LocalPlayer.Character.Animate:FindFirstChild(name)
  100. if (config ~= nil) then
  101. -- print("Loading anims " .. name)
  102. table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
  103. table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
  104. local idx = 1
  105. for _, childPart in pairs(config:GetChildren()) do
  106. if (childPart:IsA("Animation")) then
  107. table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
  108. animTable[name][idx] = {}
  109. animTable[name][idx].anim = childPart
  110. local weightObject = childPart:FindFirstChild("Weight")
  111. if (weightObject == nil) then
  112. animTable[name][idx].weight = 1
  113. else
  114. animTable[name][idx].weight = weightObject.Value
  115. end
  116. animTable[name].count = animTable[name].count + 1
  117. animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  118. -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  119. idx = idx + 1
  120. end
  121. end
  122. end
  123. -- fallback to defaults
  124. if (animTable[name].count <= 0) then
  125. for idx, anim in pairs(fileList) do
  126. animTable[name][idx] = {}
  127. animTable[name][idx].anim = Instance.new("Animation")
  128. animTable[name][idx].anim.Name = name
  129. animTable[name][idx].anim.AnimationId = anim.id
  130. animTable[name][idx].weight = anim.weight
  131. animTable[name].count = animTable[name].count + 1
  132. animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  133. -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  134. end
  135. end
  136. end
  137. -- Setup animation objects
  138. function scriptChildModified(child)
  139. local fileList = animNames[child.Name]
  140. if (fileList ~= nil) then
  141. configureAnimationSet(child.Name, fileList)
  142. end
  143. end
  144. game.Players.LocalPlayer.Character.Animate.ChildAdded:connect(scriptChildModified)
  145. game.Players.LocalPlayer.Character.Animate.ChildRemoved:connect(scriptChildModified)
  146. for name, fileList in pairs(animNames) do
  147. configureAnimationSet(name, fileList)
  148. end
  149. -- ANIMATION
  150. -- declarations
  151. local toolAnim = "None"
  152. local toolAnimTime = 0
  153. local jumpAnimTime = 0
  154. local jumpAnimDuration = 0.3
  155. local toolTransitionTime = 0.1
  156. local fallTransitionTime = 0.3
  157. local jumpMaxLimbVelocity = 0.75
  158. -- functions
  159. function stopAllAnimations()
  160. local oldAnim = currentAnim
  161. -- return to idle if finishing an emote
  162. if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  163. oldAnim = "idle"
  164. end
  165. currentAnim = ""
  166. currentAnimInstance = nil
  167. if (currentAnimKeyframeHandler ~= nil) then
  168. currentAnimKeyframeHandler:disconnect()
  169. end
  170. if (currentAnimTrack ~= nil) then
  171. currentAnimTrack:Stop()
  172. currentAnimTrack:Destroy()
  173. currentAnimTrack = nil
  174. end
  175. return oldAnim
  176. end
  177. function setAnimationSpeed(speed)
  178. if speed ~= currentAnimSpeed then
  179. currentAnimSpeed = speed
  180. currentAnimTrack:AdjustSpeed(currentAnimSpeed)
  181. end
  182. end
  183. function keyFrameReachedFunc(frameName)
  184. if (frameName == "End") then
  185. local repeatAnim = currentAnim
  186. -- return to idle if finishing an emote
  187. if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
  188. repeatAnim = "idle"
  189. end
  190. local animSpeed = currentAnimSpeed
  191. playAnimation(repeatAnim, 0.0, Humanoid)
  192. setAnimationSpeed(animSpeed)
  193. end
  194. end
  195. -- Preload animations
  196. function playAnimation(animName, transitionTime, humanoid)
  197. local roll = math.random(1, animTable[animName].totalWeight)
  198. local origRoll = roll
  199. local idx = 1
  200. while (roll > animTable[animName][idx].weight) do
  201. roll = roll - animTable[animName][idx].weight
  202. idx = idx + 1
  203. end
  204. -- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  205. local anim = animTable[animName][idx].anim
  206. -- switch animation
  207. if (anim ~= currentAnimInstance) then
  208. if (currentAnimTrack ~= nil) then
  209. currentAnimTrack:Stop(transitionTime)
  210. currentAnimTrack:Destroy()
  211. end
  212. currentAnimSpeed = 1.0
  213. -- load it to the humanoid; get AnimationTrack
  214. currentAnimTrack = humanoid:LoadAnimation(anim)
  215. currentAnimTrack.Priority = Enum.AnimationPriority.Core
  216. -- play the animation
  217. currentAnimTrack:Play(transitionTime)
  218. currentAnim = animName
  219. currentAnimInstance = anim
  220. -- set up keyframe name triggers
  221. if (currentAnimKeyframeHandler ~= nil) then
  222. currentAnimKeyframeHandler:disconnect()
  223. end
  224. currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  225. end
  226. end
  227. -------------------------------------------------------------------------------------------
  228. -------------------------------------------------------------------------------------------
  229. local toolAnimName = ""
  230. local toolAnimTrack = nil
  231. local toolAnimInstance = nil
  232. local currentToolAnimKeyframeHandler = nil
  233. function toolKeyFrameReachedFunc(frameName)
  234. if (frameName == "End") then
  235. -- print("Keyframe : ".. frameName)
  236. playToolAnimation(toolAnimName, 0.0, Humanoid)
  237. end
  238. end
  239. function playToolAnimation(animName, transitionTime, humanoid, priority)
  240. local roll = math.random(1, animTable[animName].totalWeight)
  241. local origRoll = roll
  242. local idx = 1
  243. while (roll > animTable[animName][idx].weight) do
  244. roll = roll - animTable[animName][idx].weight
  245. idx = idx + 1
  246. end
  247. -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  248. local anim = animTable[animName][idx].anim
  249. if (toolAnimInstance ~= anim) then
  250. if (toolAnimTrack ~= nil) then
  251. toolAnimTrack:Stop()
  252. toolAnimTrack:Destroy()
  253. transitionTime = 0
  254. end
  255. -- load it to the humanoid; get AnimationTrack
  256. toolAnimTrack = humanoid:LoadAnimation(anim)
  257. if priority then
  258. toolAnimTrack.Priority = priority
  259. end
  260. -- play the animation
  261. toolAnimTrack:Play(transitionTime)
  262. toolAnimName = animName
  263. toolAnimInstance = anim
  264. currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  265. end
  266. end
  267. function stopToolAnimations()
  268. local oldAnim = toolAnimName
  269. if (currentToolAnimKeyframeHandler ~= nil) then
  270. currentToolAnimKeyframeHandler:disconnect()
  271. end
  272. toolAnimName = ""
  273. toolAnimInstance = nil
  274. if (toolAnimTrack ~= nil) then
  275. toolAnimTrack:Stop()
  276. toolAnimTrack:Destroy()
  277. toolAnimTrack = nil
  278. end
  279. return oldAnim
  280. end
  281. -------------------------------------------------------------------------------------------
  282. -------------------------------------------------------------------------------------------
  283. function onRunning(speed)
  284. if speed > 0.01 then
  285. playAnimation("walk", 0.1, Humanoid)
  286. if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
  287. setAnimationSpeed(speed / 14.5)
  288. end
  289. pose = "Running"
  290. else
  291. if emoteNames[currentAnim] == nil then
  292. playAnimation("idle", 0.1, Humanoid)
  293. pose = "Standing"
  294. end
  295. end
  296. end
  297. function onDied()
  298. pose = "Dead"
  299. end
  300. function onJumping()
  301. playAnimation("jump", 0.1, Humanoid)
  302. jumpAnimTime = jumpAnimDuration
  303. pose = "Jumping"
  304. end
  305. function onClimbing(speed)
  306. playAnimation("climb", 0.1, Humanoid)
  307. setAnimationSpeed(speed / 12.0)
  308. pose = "Climbing"
  309. end
  310. function onGettingUp()
  311. pose = "GettingUp"
  312. end
  313. function onFreeFall()
  314. if (jumpAnimTime <= 0) then
  315. playAnimation("fall", fallTransitionTime, Humanoid)
  316. end
  317. pose = "FreeFall"
  318. end
  319. function onFallingDown()
  320. pose = "FallingDown"
  321. end
  322. function onSeated()
  323. pose = "Seated"
  324. end
  325. function onPlatformStanding()
  326. pose = "PlatformStanding"
  327. end
  328. function onSwimming(speed)
  329. if speed > 0 then
  330. pose = "Running"
  331. else
  332. pose = "Standing"
  333. end
  334. end
  335. function getTool()
  336. for _, kid in ipairs(Figure:GetChildren()) do
  337. if kid.className == "Tool" then return kid end
  338. end
  339. return nil
  340. end
  341. function getToolAnim(tool)
  342. for _, c in ipairs(tool:GetChildren()) do
  343. if c.Name == "toolanim" and c.className == "StringValue" then
  344. return c
  345. end
  346. end
  347. return nil
  348. end
  349. function animateTool()
  350. if (toolAnim == "None") then
  351. playToolAnimation("toolnone", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)
  352. return
  353. end
  354. if (toolAnim == "Slash") then
  355. playToolAnimation("toolslash", 0, Humanoid, Enum.AnimationPriority.Action)
  356. return
  357. end
  358. if (toolAnim == "Lunge") then
  359. playToolAnimation("toollunge", 0, Humanoid, Enum.AnimationPriority.Action)
  360. return
  361. end
  362. end
  363. function moveSit()
  364. RightShoulder.MaxVelocity = 0.15
  365. LeftShoulder.MaxVelocity = 0.15
  366. RightShoulder:SetDesiredAngle(3.14 /2)
  367. LeftShoulder:SetDesiredAngle(-3.14 /2)
  368. RightHip:SetDesiredAngle(3.14 /2)
  369. LeftHip:SetDesiredAngle(-3.14 /2)
  370. end
  371. local lastTick = 0
  372. function move(time)
  373. local amplitude = 1
  374. local frequency = 1
  375. local deltaTime = time - lastTick
  376. lastTick = time
  377. local climbFudge = 0
  378. local setAngles = false
  379. if (jumpAnimTime > 0) then
  380. jumpAnimTime = jumpAnimTime - deltaTime
  381. end
  382. if (pose == "FreeFall" and jumpAnimTime <= 0) then
  383. playAnimation("fall", fallTransitionTime, Humanoid)
  384. elseif (pose == "Seated") then
  385. playAnimation("sit", 0.5, Humanoid)
  386. return
  387. elseif (pose == "Running") then
  388. playAnimation("walk", 0.1, Humanoid)
  389. elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  390. -- print("Wha " .. pose)
  391. stopAllAnimations()
  392. amplitude = 0.1
  393. frequency = 1
  394. setAngles = true
  395. end
  396. if (setAngles) then
  397. local desiredAngle = amplitude * math.sin(time * frequency)
  398. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  399. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  400. RightHip:SetDesiredAngle(-desiredAngle)
  401. LeftHip:SetDesiredAngle(-desiredAngle)
  402. end
  403. -- Tool Animation handling
  404. local tool = getTool()
  405. if tool and tool:FindFirstChild("Handle") then
  406. local animStringValueObject = getToolAnim(tool)
  407. if animStringValueObject then
  408. toolAnim = animStringValueObject.Value
  409. -- message recieved, delete StringValue
  410. animStringValueObject.Parent = nil
  411. toolAnimTime = time + .3
  412. end
  413. if time > toolAnimTime then
  414. toolAnimTime = 0
  415. toolAnim = "None"
  416. end
  417. animateTool()
  418. else
  419. stopToolAnimations()
  420. toolAnim = "None"
  421. toolAnimInstance = nil
  422. toolAnimTime = 0
  423. end
  424. end
  425. -- connect events
  426. Humanoid.Died:connect(onDied)
  427. Humanoid.Running:connect(onRunning)
  428. Humanoid.Jumping:connect(onJumping)
  429. Humanoid.Climbing:connect(onClimbing)
  430. Humanoid.GettingUp:connect(onGettingUp)
  431. Humanoid.FreeFalling:connect(onFreeFall)
  432. Humanoid.FallingDown:connect(onFallingDown)
  433. Humanoid.Seated:connect(onSeated)
  434. Humanoid.PlatformStanding:connect(onPlatformStanding)
  435. Humanoid.Swimming:connect(onSwimming)
  436. -- setup emote chat hook
  437. game:GetService("Players").LocalPlayer.Chatted:connect(function(msg)
  438. local emote = ""
  439. if msg == "/e dance" then
  440. emote = dances[math.random(1, #dances)]
  441. elseif (string.sub(msg, 1, 3) == "/e ") then
  442. emote = string.sub(msg, 4)
  443. elseif (string.sub(msg, 1, 7) == "/emote ") then
  444. emote = string.sub(msg, 8)
  445. end
  446. if (pose == "Standing" and emoteNames[emote] ~= nil) then
  447. playAnimation(emote, 0.1, Humanoid)
  448. end
  449. end)
  450. -- main program
  451. -- initialize to idle
  452. playAnimation("idle", 0.1, Humanoid)
  453. pose = "Standing"
  454. while Figure.Parent ~= nil do
  455. local _, time = wait(0.1)
  456. move(time)
  457. end

Raw paste data: