Infinite Yield on ScreenGui?

I’m trying to access the LocalPlayer’s Screen GUI, however, it gives me an infinite yield warning/error. Is this the correct way to do it?:

local screenGui = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")

Well it yields infinitely because it’s waiting on a child of PlayerGui that just doesn’t exist. Are you sure the ScreenGui is parented to PlayerGui and exists?

You can try something like,

local Player = game.Players.LocalPlayer

if not Player.PlayerGui:FindFirstChild("ScreenGui") then
    print("ScreenGui does not exist.")
end
1 Like

Ah typical spelling mistake, I do it a lot too. :+1:

i thought she was talking about countering infinite yield, the exploit