ZKCMCheats

R15 to R6 (maybe works)

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