Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't this animation gui work?

Asked by 9 years ago
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)
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). Redbullusa 1580 — 9y

1 answer

Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

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)
0
It still doesn't work in-game... alonzo12345 60 — 9y
Ad

Answer this question