Tool Animation Error?

This might be SUPER simple solution but for some reason it’s not working, (I’ve made this before)

Okay so- I am trying to make an animation for my cupcake, and it’s not working.

  1. Yes my animation is made by the game’s owner (group).

image
Local Script :

1 Like

There’s a few thing wrong with this,

I would suggest using Tool.Activated instead of Mouse.Button1Down both because of mobile support and because it’s more accurate. (If a player clicks a gui you don’t want it to play the animation)

You’re also loading the animation from the wrong Instance, the tool does not have a child Animation it’s the handle that has the animation.

1 Like

See lynnlo’s message above. ^ Also, did you set the AnimationPriority?

So I did this- not sure if I did it right… I’m such a noob at basic things LOL

Tool was not defined, replace that with script.Parent.
Also place the function outside of equipped.


Is that right?

Do you have a scripter for your game? Try asking him or her to do it.

Watch a few videos on tools and basic lua syntax to get a better understanding of the code.

Removing lines 1 and 6 should make the script work.

Is this a script or localscript?

You’re describing animation only in Equipped function, it’ll be better to make it a variable above all of them. For your scenario, you’d use:

local tool = script.Parent
local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(tool.Animation)
tool.Equipped:Connect(function()
    tool.Activated:Connect(function()
        anim:Play()
    end)
end)
tool.Unequipped:Connect(function()
     anim:Stop()
end)

Did you define the Animation ID?

local tool = script.Parent
local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(tool.Animation)
tool.Equipped:Connect(function()
tool.Activated:Connect(function()
anim:Play()
end)
end)
tool.Unequipped:Connect(function()
anim:Stop()
end)

What @Doqee said will fix it. For example if you have a variable in a function you will only be able to use that variable inside that function. So when you put the animation variable only in the equip the unequipped can’t use it. The easiest way to fix this is by what @Doqee provided!
Have a nice day