Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What's the best way to play an animation on click?

This is my first approach. But this seems stuttering a lot for me. What's the best and simplest way?

script.Parent.Equipped:Connect(function(mouse)
	mouse.Button1Down:Connect(function()
		local slash = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Slash)		
	end)
end)

1 answer

Hello. The problem is that you did not :Play() the animation. Also, I'd use Tool.Activated as it fires when a Tool is clicked and it just saves you lines of code. Here is the code that will work:

script.Parent.Activated:Connect(function()
		local slash = game:GetService("Players").LocalPlayer.Character.Humanoid:LoadAnimation(script.Slash)
		slash:Play()       
	end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.