How to make an animation in tool script? Like when I equip a tool and then left-click, an animation would trigger. How would I make that?
I am at school atm, this means I can't test this code. Let me know if there are any problems.
PLEASE read the comments!
--// In LocalScript local Player = game.Players.LocalPlayer --finds player local Character = Player.Character or Player.CharacterAdded:Wait() --find player's character, if not, waits for character to be added TOOL.Equipped:Connect(function() --when we equip the tool TOOL.Activated:Connect(function() --when we click when having the tool equipped local Anim = Instance.new('Animation', Character) --makes animation Anim.AnimationId = 000000000 --id here PlayAnim = Character.Humanoid:LoadAnimation(Anim) --this is a global variable so that we can call the "Stop()" function to stop the animation outside the Equipped function. PlayAnim:Play() end) end) TOOL.UnEquipped:Connect(function() --when we unequip the tool PlayAnim:Stop() end)
script.Parent.Equipped:connect(function(namewhat) script.Parent.Activated:connect(function(click) -- animation script here end) end)