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

Humanoid is not a valid member of Backpack?

Im trying to make an animation end when the player unequips the tool. Heres the script:

function Unequipped()
	local IdleAnim = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.IdleAnim)
	if script.Parent.IdleAnim then script.Parent.IdleAnim:Stop() end
end

I already know the reason, but how do i fix this?

Edit: Here's the edited script

function Unequipped()
	local IdleAnim = script.Parent.Parent.Parent.Character.Humanoid:LoadAnimation(script.Parent.IdleAnim)
	IdleAnim:Stop()
end

I have done what DepressionSensei has said, but it still doesnt work. The animation still doesnt stop. Heres the video to demonstrate: https://www.youtube.com/watch?v=h2ZfLWEWG9Q&feature=youtu.be

5 comments

0

I'm not going to be surprised when i wake up in the morning and find no answers yet.

0

You posted this at nighttime. Try to post your question at prime time, which is in the middle of the day.

0

So i should wait until afternoon to post my question?

0

Use a LocalScript :D

0

I've been working on this for 2 days, still havent found a solution.

1 answer

script.Parent.Parent.Parent.Character.Humanoid I already know you know this, but if you really understood, you probably would've been able to fix this already. When a player unequips a tool, it leaves from the character's children and moves to the player's backpack. If you're getting an error that the Humanoid isn't a valid member of the backpack, that's why. The parent of the character is the player, so you can jump back to one more parent, the player, and index the character to fix your script.

Hope this helped, remember to accept if it did :)

3 comments

0

Now it thinks "Stop is not a valid member of Animation."

0

And when i remove script.Parent from the third line, the output says nothing and the animation wont stop.

0

That's odd. If you got a Backpack error, then moving up one more parent to the player would've fixed your problem. And if you remove script.parent, the script will break because the script won't know where you're getting the animation from. Parent the IdleAnim to the script's parent and that would fix that problem

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