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

Why won't this animation gui work?

local button = script.Parent

local user = game.Players.LocalPlayer

local char = user.Character

local humanoid = char.Humanoid

local anim = humanoid:LoadAnimation(button.Anim)

function action()
	anim:Play()
	wait(1)
	anim:Stop()
end


button.MouseButton1Down:connect(action)

1 comment

0

Be sure that this is a local script (it has to be, since you're using LocalPlayer) and it's parented in (or is a descendant of) StarterGui (or StarterPack).

1 answer

✓ Accepted answer

Wait for the Character object, Humanoid, and the animation object!

local button = script.Parent

local user = game.Players.LocalPlayer

local char = user.Character or user.CharacterAdded:wait()

local humanoid = char:WaitForChild("Humanoid")

local anim = humanoid:LoadAnimation(button:WaitForChild("Anim"))

function action()
    anim:Play()
    wait(1)
    anim:Stop()
end


button.MouseButton1Down:connect(action)

1 comment

0

It still doesn't work in-game...

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