Anybody know why this error is happening? (Gui Error)

This error doesn’t really need any explanation, I’m just a bit confused as to why this error is happening even though I think I did everything right. Here are the 2 pictures.

Screen Shot 2021-04-09 at 7.21.01 PM

1 Like

Maybe because the client load the things too fast that the server is late to replicate the GUIs to them.

1 Like

Define your Gui’s by using

local PlayerGui = Player:WaitForChild("PlayerGui")
local StageGui = PlayerGui:WaitForChild("StageGui")

That way the code will yield until the Player’s Gui has been found

maybe your roblox playtest is loading too long, that the code just finds and says it doesn’t exist. try using WaitForChild() or repeat wait() until script.Parent:FindFirstChild(‘StageGui’)

I wouldn’t advise using a repeat wait() loop, just use WaitForChild() it’s a better approach

why i use repeat wait until:

wait for child can have a timeout even if i set it to math.huge, so i use repeat until too

I would recommend storing all your GUIs in ReplicatedStorage and cloning them over to the player’s PlayerGui like in the video below. Not only does this avoid using all those yucky WaitForChild calls, but it also significant reduces server memory usage since the server isn’t keeping a copy of every GUI for every player.

1 Like