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

Unable to cast value to Object?

Asked by 5 years ago
Edited 5 years ago

I'm trying to get this idle animation for my gun to load, but it keeps giving me the "Unable to cast value to object" error. I'm not sure how to go about with this error, and I don't know where to start to solve this issue.

tool.Equipped:Connect(function(mouse)
    Equipped = true
    local h = Player.Character.Humanoid:LoadAnimation("Idle")
    h:Play()
end

It sends me to this block of code every time it gives me the error. So this is the point where I am stuck. Mind helping me?

0
Which line is it on? DeceptiveCaster 3761 — 5y
0
Line 3. marltonjohnson9876 11 — 5y
0
Do you have a Player variable? We need to see the whole script. TheOnlySmarts 233 — 5y
0
I fixed it. I accidentally use the name of the animation as a string value. marltonjohnson9876 11 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I couldn't use the name "Idle" as a string for the animation. I had to put in the actual animation object within the gun.

Ad

Answer this question