Do i have to run an animation from a local script for it to work?

I want to make it so that when a player clicks a click detector, an animation plays. I have searched everywhere but i cant find the answer. I make the animation play in a local script in a tool but cant play the animation in a normal script. Does anybody know how to get that done?

Thanks

1 Like

You can run it from a server side and local scripts

Not specifically, the animation can be played from either a LocalScript or a normal Script. Would you care to show us your code or the error you’re running into?

Maybe this script will help you.

local part = -- path to part
local clickDec = -- your ClickDetector
local animation = -- your animation

clickDec.MouseClick:Connect(function(Player)
if Player.Character:FindFirstChild("Humanoid") then

local animTrack = Player.Character.Humanoid:LoadAnimation(animation)

animTrack:Play() -- playing animation
end
end)
4 Likes

Is your animation priority set to action? If not, the animation will be overwritten by another animation. Also, it’s better to use Animator:LoadAnimation, but if there is no animator then what you are doing is fine. Also, if you really want it to work with a local script then use a remote event because this is only for one button, and you would have to rewire it for every other button.

1 Like