This is the code I have so far:
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local character = Player.Character local Tools = Player.Backpack local startgear = Player.StarterGear local Animation = game.ServerStorage.Animation function makegearstart() for i,v in pairs(Tools:GetChildren()) do v:clone().Parent = startgear end end makegearstart() ------------------------------------------- function speed(speed) character.Humanoid.WalkSpeed = speed -- speed function end function holdingtool() for _, child in pairs(character:GetChildren()) do if child.ClassName == "Tool" then child:remove() end end end function givebacktool() for i,v in pairs(startgear:GetChildren()) do v:clone().Parent = Tools end end Mouse.KeyDown:connect(function(Key) -- main thing if Key == "x" then if character.Humanoid.WalkSpeed > 0 then speed(0) Tools:Remove() holdingtool() Animation:Play() else speed(16) givebacktool() Animation:Pause() end end end)
On the parts where it says "Animation:Play()" and "Animation:Pause()" I cannot get it to play the actual animation. Help?
My answer has not been tested. Let me know if it works.
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local character = Player.Character local Tools = Player.Backpack local startgear = Player.StarterGear local Animation = game.ServerStorage.Animation function makegearstart() for i,v in pairs(Tools:GetChildren()) do v:clone().Parent = startgear end end makegearstart() ------------------------------------------- function speed(speed) character.Humanoid.WalkSpeed = speed -- speed function end function holdingtool() for _, child in pairs(character:GetChildren()) do if child.ClassName == "Tool" then child:remove() end end end function givebacktool() for i,v in pairs(startgear:GetChildren()) do v:clone().Parent = Tools end end local animtrack animtrack = player.Character.Humanoid:LoadAnimation(Animation) Mouse.KeyDown:connect(function(Key) -- main thing if Key == "x" then if character.Humanoid.WalkSpeed > 0 then speed(0) Tools:Remove() holdingtool() animtrack:Play() else speed(16) givebacktool() animtrack:Pause() end end end)