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

animation not working when I click button??

I'm making a script where u click a button and it plays the animation. Something is wrong and here is the code:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local hum = char.Humanoid
local idle = hum:LoadAnimation(script.Animation)

script.Parent.MouseButton1Click:Connect(function()
	idle:Play()
end)

the system says there is something wrong with line 3 but I have no clue what it is

1 answer

I think it's because the Humanoid hasn't loaded up yet, but not sure.

local hum = char:WaitForChild("Humanoid")

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