Advertisement
Hmm465_Gaming

r6 script

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