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

Unable to cast value to Object?

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?

4 comments

0

Which line is it on?

0

Line 3.

0

Do you have a Player variable? We need to see the whole script.

0

I fixed it. I accidentally use the name of the animation as a string value.

1 answer

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.

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