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

Why doesnt "While not" loop work? [Solved]

20:36:51.736 - BodyGyro is not a valid member of Part 20:36:51.736 - Script 'Players.Player1.Backpack.Working Camera', Line 7

I insert the bodygyro when a player is added. So why doesn't it wait? Here's line 7

while not character.HumanoidRootPart.BodyGyro do wait() end

Simple loop, so why doesnt it work?

1 answer

I think the reason it says that is because BodyGyro hasn't loaded yet.

Use the term :WaitForChild() to load it

So :WaitForChild("BodyGyro") would wait for it to load before letting the script run without it.

3 comments

0

It gives me this 20:48:27.575 - WaitForChild called on an Instance that is not in a DataModel. 20:48:27.575 - Script 'Players.Player1.Backpack.Working Camera', Line 6

0

Have you tried replacing the old script with character.HumanoidRootPart:WaitForChild("BodyGyro")

0

Yes.

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