Advertisement
Glexteon

R6

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