script.Parent.Salute.MouseButton1Click:Connect(function()
loadanim = humanoid:WaitForChild("Animator"):LoadAnimation(script.Parent.Salute:WaitForChild("SaluteAnim"))
if not loadanim.IsPlaying then
loadanim:Play()
else
loadanim:Stop()
end
end)
Hmmm …
First you don’t need to reload the anim every time a player click so set your variable for first !
It should look like this :
local Button = script.Parent.Salute
local Animator = humanoid:WaitForChild("Animator")
local Animation = Button:WaitForChild("SaluteAnim")
local LoadedAnimation = Animator:LoadAnimation(Animation)
Button.MouseButton1Click:Connect(function()
if not LoadedAnimation.IsPlaying then
LoadedAnimation:Play()
else
LoadedAnimation:Stop()
end
end)
But do you want to play the anim and after stop it or when the player click play it and stop it when a player re click ?
Have a nice day !
“First you don’t need to reload the anim every time a player click”
I made this because Im having many animations in that script and yes I want to make it that you can click on a button then the animation starts and if you click again it stops playing but it won’t stop. I also dont get any kind of error code.