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

animation not working when I click button??

Asked by 4 years ago

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

Log in to vote
1
Answered by
TtuNkK 37
4 years ago

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

local hum = char:WaitForChild("Humanoid")
Ad

Answer this question