SurfaceGui Children appearing nill when testing

Hello! I’m trying to index certain children under a surface gui, and when i test or play the game, and try to index the text box for instance, it keeps return as nil, or that it cant find what its trying to look for. In the workspace in the test it says it is there, but the scripts cant seem to index it. Archivailable is on, and i’ve tried to print the location of what i’m trying to index in the command bar, but still nothing. Does anyone have any ideas about this?

1 Like

can you paste some code or photo of it pls

1 Like
local CharacterStuff = game.Workspace.Spawn_Game.Gyspy_Circus.CharacterStuff
local NameBoard = CharacterStuff.NameBoard:WaitForChild("Name"):WaitForChild("Info")
local DescBoard = CharacterStuff.DescBoard:WaitForChild("Desc"):WaitForChild("Info")
NameBoard.Text = Name
DescBoard.Text = Desc

This is in the server, but it’s a surface gui and should work in the server the “Info” is whats coming up nil. The “Name” or “Desc” which is the surface gui’s themselves are being indexed.

1 Like

You could set it via localscript and place the localscript in CharacterStuff
so it would be like

local NameBoard = script.Parent.NameBoard.Name.Intro

no waitforchild needed (I believe) since the localscript is present in the gui itself

1 Like

i too dont understand why use wait for chield i declarate this like “example.example.example” and it work

1 Like

Hmm it was weird, i deleted the text box and redid it, and redid it, and now its working :confused:

1 Like

WaitForChild is used if you want to refrence something that is going to be placed there but is not there yet

1 Like

This is not true. Even though an object exists in Studio, it still may not load in time while in game. Though it is quite excessive, WaitForChild is not improperly used in @Manelin 's code.

2 Likes

Alright, thanks for correcting me. Didn’t know

1 Like