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

How to make player play an animation?

local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
script.Parent.ScreenGui.TextButton.MouseButton1Click:Connect(function()
		animation:Play()
		wait(1)	
end)

LocalScript inside StartGUI

When you press a button the animation will play but it didnt

2 answers

✓ Accepted answer

You're over thinking it

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded
local hum = char:WaitForChild("Humanoid")

script.Parent.MouseButton1Click:connect(function()
	local anim = hum:LoadAnimation(script.Parent.Animation)
	anim:Play()
end)

and make sure that your animation priority is set as action if its an animation that is quick and isn't looped

2 comments

0

and make sure u put the local script inside the button and make sure the animation is in the button too

0

works

Buttons use the activated event, not the mousebutton1down event

try this:

local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
script.Parent.ScreenGui.TextButton.Activated:Connect(function()
        animation:Play()
        wait(1)
end)

1 comment

0

dont work

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