WaitForChild is not a valid member of PlayerGui

WaitForChid is not a valid member of PlayerGui

local gui = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChid("ScreenGui2")
1 Like

Im pretty sure Child is spelt as Child not Chid

2 Likes

You mispelled WaitForChild, its written WaitForChid

Other thing is that you might use the second parameter of waitforchild which is the ammount of time it needs to wait so it can stop waiting for the child, in some cases if you dont put this , the game will say screenGUI aint a child of playerGUI

So basically you can put some time in it like WaitForChild(“ScreenGui”, 20) (So basically this will wait for the child for 20 seconds if it doesnt appear during that time then it will say its not a member)

1 Like

If you don’t specify the second argument, all you’ll get is an infinite yield error - it won’t ever under normal circumstances index quicker then ‘screenGui’ would take to exist or anything, and you’ll just be yielding until the error shows up (you won’t get a ‘is not a valid member’ or ‘child of’ error).

In most cases it’s just fine to not specify how long you want it to yield for if you’re sure the object is to exist sometime in the future at all.

1 Like

Actually no, I used the waitforchild in some GUIs and items (and the child i was waiting for was already there) but it still said infinite yield.

But it’s just a safety thing

I don’t believe you get what I meant,
the infinite yield error is something else, and a “is not a valid member of” error is something else, so you won’t get this error by not specifying the second parameter:

On another note,

Already where? It takes time for instances to replicate for every client

Edit:

Unless from replicated first, don’t call ReplicatedStorage:WaitForChild(), there are several posts explaining the why.

You’ll get the error only if instances just take a bit more than 5 seconds to exist, there’s so many reasons why that could happen.

1 Like

It was at the studio already, I tested in workspace, replicated storage and starterGUI and they all did the infinite yield error until i specified the 2nd parameter.

But as I said it is for safety.