Trouble with play animation on tool click

Hi! I am attempting to create an animation script, where when a tool is clicked, the animation plays. I have tried many tutorials, but the selected few I chose did not work. Any suggestions? Any tutorials you can link?

Thanks for reading!

Crrustyy

3 Likes

you want to put a script in that tool and do the following:

local animation = --where the animation is here

script.Parent.Activated:Connect(function()
    animation:Play()
end)
3 Likes

Alright, I’ll see if it works! Thanks a lot!

2 Likes

I don’t doubt that there are working tutorials out there and you may be missing out on the fundamental knowledge needed to assemble these together, but these are the kinds of things you should try out yourself before posting a thread. Usually you should attempt first, then try tutorials. Tutorials alone won’t help you resolve problems and may not be available for the subject matter you’re looking at.

When you have a question, define your requirements and then search. There are two parts to understanding how to get this done: finding out how to determine when a tool is clicked and how to play an animation.

First off, this thread has some useful information that you can salvage:

Next is to determine how to find out when a tool clicks. To do this, navigate to the Tool API page and look for an event relevant to your case. Activated can work out for you, as it is fired when the player clicks the left mouse button.

How do you get an animation? First, you need to index the character’s Humanoid as well as the animation object you want, then load the animation onto the Humanoid. This gives you an AnimationTrack back, which has a play method to run the animation.

Put this all together and your problem is solved.

4 Likes

Wow thank you! I will remember this next time I post! What a lovely community!