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

WaitForChild 'Infinite Yield Possible', Help?

Hi, I've been having a lot of trouble over the past days trying to figure this out but nothing is working. I've tried to look for understanding on what it means by infinite yield is possible, and I've tried so much, but nothing is working. Here is my script.

for i, player in pairs (game.Players:GetPlayers()) do
player.PlayerGui:WaitForChild('playerInterface')
end

function Intermission(TextValue)
for i, player in pairs (game.Players:GetPlayers()) do
if player:FindFirstChild("PlayerGui") and player:FindFirstChild("PlayerGui"):FindFirstChild("playerInterface") then
	player.PlayerGui.playerInterface.intermission.Text = tostring(TextValue)
end
end

Whenever I dont put in the WaitForChild() the gui doesnt work, when I do put it in, an Infinite Yield comes up and the script itself entirely breaks. However, I found a solution, but then whenever I would be to reset my character, It would completely remove the GUI ( I used clone(). ) This is in a regular script.

Any help would be much appreciated, thank you for your time reading this.

5 comments

0

Try just using a "wait(1) at the top of the script or however long it takes for it to load

0

I'm not sure how it is if you have FilteringEnabled disabled, but at least when it's enabled the server doesn't have access to players' PlayerGuis (meaning that the WaitForChild will never return, triggering the warning you got)

0

@chess123mate, If that's the case, how will the game work in terms of the new update where it is a component to have filtering enabled if you want like i think its ages under 13 to play your game

0

@chess123mate, Nevermind, Thanks for your help it worked!

1

If your script ends up not working, check out the guides at the top of Scripting Helpers for RemoteEvents/Functions and server/client communication. Ideally the server would use RemoteEvents to broadcast to clients when intermissions start/end and what text to display.

1 answer

✓ Accepted answer

"Infinite Yield". I found this kind of stuff difficult when I started, don't worry. Yield means kind of like a wait() statement. Basically it means Infinite wait. This means it can infinitely stop running because the WaitForChild() finds nothing. It does Yield the script after all. Make sure the player has an object in the PlayerGui named 'playerInterface'.

3 comments

0

Okay, basically the startergui has a property in it that has 'playerInterface' and whenever the game runs I put that :WaitForChild() at the start with a wait(1) at the top yet nothing happens.

0

Nevermind, Thanks for your help!

0

Yield is not just in programming, it is in English. We don't pull random words out of the sky and hope that people know what it means.

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