Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a looped animation when holding a tool? [closed]

Asked by 5 years ago

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).

0
you might need a script, what i can fix gloveshun 119 — 5y

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?

2 answers

Log in to vote
0
Answered by 5 years ago

in the animation editor itself, making an animation that has a higher priority than Movement, also making it a loop.

How to loop

How to set priority

to play the animation, you must load it into the humanoid with local AnimTrack = Humanoid:LoadAnimation(Animation)

wiki page

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)

Tool.Equipped

Tool.Unequipped

Ad
Log in to vote
0
Answered by
pwx 1581 Moderation Voter
5 years ago

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)