Fix "Infinite Yield Possible" WaitForChild Warning in Roblox
What the Roblox "Infinite yield possible" warning means, the five common causes behind it, and how to fix WaitForChild calls with timeouts and nil checks.
On this page
- What the warning actually means
- How to find the cause
- Cause 1: The name or parent is wrong
- Cause 2: A LocalScript is waiting for something it can’t see
- Cause 3: The script that should create the object failed
- Cause 4: Streaming hasn’t sent the part to the client
- Cause 5: The character isn’t ready yet
- Add a timeout and handle nil
- When to use FindFirstChild instead
- If it still doesn’t work
- Related guides
- Sources
The “Infinite yield possible” warning in Roblox Studio means a WaitForChild() call has been waiting more than 5 seconds for an object that hasn’t shown up. The script isn’t broken yet, but the line is stuck, and nothing after it runs. This guide explains what triggers the warning and how to fix each cause.
What the warning actually means
WaitForChild(childName, timeOut) returns the child with that name. If the child already exists, it returns right away. If it doesn’t, the current thread pauses until the child appears.
According to the Creator Hub reference, if the call runs for more than 5 seconds and you didn’t pass a timeOut, Roblox prints a warning that the thread may yield indefinitely. That’s the message you see in the Output window, usually in this form:
Infinite yield possible on 'ReplicatedStorage:WaitForChild("ScoreEvent")'
The part in quotes is the most useful clue. It tells you the parent that was searched (ReplicatedStorage) and the name that was expected (ScoreEvent). Click the warning in Output to jump to the line that made the call.
How to find the cause
Work through the causes below in order. The first two are the most common and the quickest to check.
flowchart TD
A["Infinite yield warning"] --> B{"Name and parent correct?"}
B -->|"No"| C["Fix the name or path"]
B -->|"Yes"| D{"Inside ServerStorage?"}
D -->|"Yes"| E["Move it to ReplicatedStorage"]
D -->|"No"| F{"Created by a script?"}
F -->|"Yes"| G["Check Output for that script's error"]
F -->|"No"| H["Check streaming or character load"]
Cause 1: The name or parent is wrong
WaitForChild looks for a direct child with an exact name match. It does not search deeper folders. So these all lead to an infinite wait:
- A typo or different capitalization (
scoreEventvsScoreEvent). - The object was renamed in the Explorer, but the script still uses the old name.
- The object sits inside a folder, but the script waits on the folder’s parent.
To fix it:
- Copy the name from the warning.
- Find the object in the Explorer and compare its name character by character.
- Check that its parent matches the parent shown in the warning. If it’s inside a folder, wait for the folder first, then the object:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remotes = ReplicatedStorage:WaitForChild("Remotes")
local scoreEvent = remotes:WaitForChild("ScoreEvent")
The first line gets the ReplicatedStorage service. The second waits for the Remotes folder, and the third waits for ScoreEvent inside that folder. Each call only checks one level.
Cause 2: A LocalScript is waiting for something it can’t see
Not everything on the server replicates to players. The Creator Hub states that objects in ServerStorage never replicate to the client and can’t be reached from LocalScripts. The same goes for ServerScriptService. A LocalScript that waits for something in either place will wait forever.
To fix it, move anything the client needs into ReplicatedStorage, which the docs describe as the container both the server and the client can access. RemoteEvents, shared ModuleScripts, and UI templates usually belong there.
Cause 3: The script that should create the object failed
Sometimes the object isn’t placed in Studio at all. A server script creates it at runtime, for example a leaderstats folder or a RemoteEvent made with Instance.new. If that script errors before it reaches the line that creates and parents the object, every script waiting for it shows the warning.
- Scroll up in Output and look for a red error from the creating script. The yield warning is often a side effect of that earlier error.
- Check that the script is enabled and placed where it runs (server scripts in ServerScriptService or Workspace).
- Make sure it sets
Parenton the new object. An object that’s created but never parented can’t be found.
Cause 4: Streaming hasn’t sent the part to the client
With instance streaming turned on, the client doesn’t get every part in the Workspace when it joins. Parts and models are sent as the player gets close and can be removed again when they’re far away. A LocalScript waiting for a distant part can easily hit the 5-second mark.
The Creator Hub’s streaming guide covers a few options:
| Option | What it does | When to use it |
|---|---|---|
| Handle the wait in code | Use a timeout and react when the part arrives later | Most cases, especially far-away parts |
ModelStreamingMode = Atomic | The model and its initial descendants stream in together | Models whose parts must arrive as one unit; wait on the model, not each part |
ModelStreamingMode = Persistent | The model is sent soon after the player joins and is never streamed out | Rare cases only; the docs warn overuse can hurt performance |
For Persistent models, the docs say client scripts should wait for the model’s PersistentLoaded event before using it. Change streaming settings with care, since turning streaming off changes how your whole experience loads.
Cause 5: The character isn’t ready yet
The Creator Hub notes that Player.Character is nil until the player’s character first spawns, and it’s replaced on every respawn. Scripts that wait for parts of an old or not-yet-spawned character can get stuck. A safer pattern in a LocalScript is:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
This uses the current character if it exists, otherwise it waits for the CharacterAdded event. Only then does it wait for the Humanoid inside that character. If your script needs to run again on every respawn, connect to CharacterAdded instead of running once. The related PlayerCharacterDestroyBehavior change also affects how old characters are cleaned up.
Add a timeout and handle nil
Once the cause is fixed, give WaitForChild a timeout. The reference says that with timeOut set, the method returns nil after that many seconds, and the 5-second warning isn’t printed.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local scoreEvent = ReplicatedStorage:WaitForChild("ScoreEvent", 10)
if not scoreEvent then
warn("ScoreEvent never showed up in ReplicatedStorage")
return
end
scoreEvent:FireServer()
The second argument (10) caps the wait at 10 seconds. If the object is still missing, scoreEvent is nil, so the if block prints your own clear message and stops the script instead of causing an “attempt to index nil” error on the next line. Test this in Studio with Play and watch the Output window.
When to use FindFirstChild instead
WaitForChild is meant for objects that might not exist yet. The Creator Hub says it matters most in LocalScripts, because the engine doesn’t guarantee when or in what order objects replicate from the server.
If you expect the object to already exist, for example a part you placed in Studio that a server script reads, use FindFirstChild() and check the result:
local door = workspace:FindFirstChild("Door")
if door then
door.Transparency = 0.5
end
FindFirstChild returns nil right away when nothing matches, so it never yields and never prints this warning. Also avoid calling either method over and over in fast loops. The reference recommends storing the result in a variable once and reusing it.
If it still doesn’t work
- The warning only appears in a published game: large experiences may need more than 5 seconds to load, so a short delay can trigger it even when nothing is wrong. Use a timeout that fits your game.
- The path in the warning starts with
CoreGui: that call comes from Roblox’s own scripts, not yours. Your code can’t fix it. - It happens after a teleport or in a team test: compare how places load in that setup. Our guide to testing teleports in Studio covers multi-place testing.
A good habit: whenever you add a WaitForChild call, ask whether the object can ever be missing. If the answer is yes, give it a timeout and decide what the script should do when it returns nil.
Related guides
- Fix “X Is Not a Valid Member of Y” Errors in Roblox Studio
- Fix “Attempt to Index Nil With” Errors in Roblox Studio
- Fix “Attempt to Perform Arithmetic on Nil” in Roblox Luau
- Roblox RemoteEvent Not Firing? How to Fix OnServerEvent
Sources
- Instance class reference: WaitForChild and FindFirstChild (Roblox Creator Hub)
- Instance streaming (Roblox Creator Hub)
- ServerStorage class reference (Roblox Creator Hub)
- Player class reference: Character (Roblox Creator Hub)
- Infinite yield possible on ‘CoreGui:WaitForChild(“TopBarApp”)’ (Roblox DevForum)
- Infinite yield possible warning, how do I fix it? (Roblox DevForum)
Frequently asked questions
What does "Infinite yield possible" mean in Roblox?
A WaitForChild call has waited more than 5 seconds without finding the child it asked for, and no timeout was given. Roblox prints the warning because the script may keep waiting forever.
Is the Infinite yield possible warning an error?
No. It is a warning, and the script does not stop. But the thread that called WaitForChild is still paused, so any code after that line has not run yet.
How do I stop the Infinite yield possible warning?
Fix the reason the child is missing first: a wrong name or parent, an object in ServerStorage, a server script that never created it, or streaming. Then pass a timeout as the second argument and handle the nil it returns when the child never shows up.
Why does WaitForChild work on the server but not in a LocalScript?
Clients cannot see everything the server can. Anything inside ServerStorage or ServerScriptService never replicates to clients, and with streaming enabled, distant parts may not be on the client yet.