Player GUI Infinite Yield

--// Services
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")
local TweenService = game:GetService("TweenService")
--// Variables
local plr = Players.LocalPlayer
local EggsFolder = Workspace:WaitForChild("Eggs")
local GameClient = ReplicatedStorage:WaitForChild("GameClient")
local PetsFolder = GameClient:WaitForChild("Pets")
local ClonesFolder = GameClient:WaitForChild("Clones")
--// UI Variables
local PlayerGui = plr:WaitForChild("PlayerGui")

This seems a bit weird for some reason it says.

Infinite yield possible on ‘Players.FelixProfit.PlayerGui:WaitForChild(“MainUI”)’

Screen Shot 2021-01-15 at 12.13.14 PM

Wait this seems to be a studio bug. Sometimes it yields sometimes it doesn’t

Maybe just make it wait longer. By default it’s 5 seconds I believe.

If your code works, then you are good. The infinite yield shows up depending on how long it takes you to load into your game, if you load into it quick then it probably won’t show up, if there is lag or it is super slow, it will probably throw that warning. But then after your character loads in it fixes itself. As long as the code works of course, which I would guess so given that you said it happens only sometimes.

You can prevent that by utilizing the second argument in WaitForChild which is how long you want it to wait in seconds until it returns “nil” if it didn’t find the object.

WaitForChild("thing", 5)

1 Like

I get that warning all the time if my game takes longer to load, the warning just pops up because it thinks that the thing isn’t there, when really it just needed a little more time to wait.