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