Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

WaitForChild 'Infinite Yield Possible', Help?

Asked by
xEiffel 280 Moderation Voter
6 years ago

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.

0
Try just using a "wait(1) at the top of the script or however long it takes for it to load PolyyDev 214 — 6y
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) chess123mate 5873 — 6y
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 xEiffel 280 — 6y
0
@chess123mate, Nevermind, Thanks for your help it worked! xEiffel 280 — 6y
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. chess123mate 5873 — 6y

1 answer

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
6 years ago

"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'.

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. xEiffel 280 — 6y
0
Nevermind, Thanks for your help! xEiffel 280 — 6y
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. hiimgoodpack 2009 — 6y
Ad

Answer this question