I've got this animation that I want to loop whenever I hold a certain tool, the animation should stop when I unequip the tool. So can someone tell me how I'd do that? (NOTE: I don't need an already existing script to be fixed, I just need someone to tell me how).
COMMUNITY QUESTION
How do I make a looped animation when holding a tool?
2 answers
in the animation editor itself, making an animation that has a higher priority than Movement, also making it a loop.
to play the animation, you must load it into the humanoid with
local AnimTrack = Humanoid:LoadAnimation(Animation)
and then play the track when tool is equipped
AnimTrack:Play()
and stop when it's unequipped
AnimTrack:Stop()
(i assume you already know how to use Tool.Equipped and Tool.Unequipped)
You just set the animation to loop, once you've done that do the following:
- Create a new Animation instance.
- Put the animation in the game. (Somewhere like in your tool or ReplicatedStorage).
- Put the AnimationId in the Animation Instance.
- Make the animation a variable, preferably in a LocalScript.
- Put this in the LocalScript (put the LocalScript in the Tool):
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Animation = game.ReplicatedStorage:WaitForChild('Animation')
local ToolAnim = Character:WaitForChild('Humanoid'):LoadAnimation(Animation)
Tool.Equipped:Connect(function()
ToolAnim:Play()
end)
Tool.Unequipped:Connect(function()
ToolAnim:Stop()
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
you might need a script, what i can fix
please follow https://scriptinghelpers.org/help/how-post-good-questions-answers