Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Infinite yield possible on 'ServerScriptService:WaitForChild("TP")?

when i was scripting something i said "game.ServerScriptService:WaitForChild("TP").RemoteFunction:InvokeServer()" then it said: "Infinite yield possible on 'ServerScriptService:WaitForChild("TP")'" but the object was there!

1 answer

ANSWER: WaitForChild() pauses the thread so as to wait for something that you specify (in your case this "TP" thing) to load and then reference it. However it has already loaded and will not load again thus giving you an infinite yield or in other words an infinite wait for this object to load, when it is already loaded, and will not load again.

FIX: use FindFirstChild("TP")

Note: WaitForChild() is meant for variables that you are declaring at the start of the code, whilist everything may still be loading in.

This discussion is preserved as it was. New answers, comments, and votes are closed.