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).
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:
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)
Closed as Not Constructive by Elixcore and User#5423
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?