I’m working on a Hud UI & ran into the following issue - The UI works brilliantly first time, however, once the Player resets / dies, I begin receiving errors.
21:32:13.510 - Infinite yield possible on ‘Limit:WaitForChild(“Drop”)’
Pre-Reset:
Post-Reset:
Limit:WaitForChild("Drop")["Planet"]["_Name"].Text = inRegion.Value
Limit:WaitForChild("Drop")["OwnedBy"]["Short"].Text = OwnedBy.Value
inRegion.Changed:Connect(function(Val)
Limit:WaitForChild("Drop")["Planet"]["_Name"].Text = Val
Limit:WaitForChild("Drop")["Stores"]["Short"].Text = CheckStores()
Limit:WaitForChild("Drop")["Jobs"]["Short"].Text = CheckJobs()
if Val == "Nevarro" then
Limit:WaitForChild("Drop")["Planet"]["Short"].Text = "NV"
elseif Val == "Endor" then
Limit:WaitForChild("Drop")["Planet"]["Short"].Text = "EN"
else
Limit:WaitForChild("Drop")["Planet"]["Short"].Text = "-"
end
end)
OwnedBy.Changed:Connect(function(Val2)
Limit:WaitForChild("Drop")["OwnedBy"]["Short"].Text = Val2
end)
First of all, that is not an error. This is a warning. You are getting this because you are using :WaitForChild(). You do not need to use :WaitForChild() that much. The warning means that it can be held for an infinite amount of time because if the object it is trying to find isn’t there, it will wait until it is. You can just replace :WaitForChild() with :FindFirstChild() if you aren’t actually waiting for any object.
For example:
print("This will run")--This code is ran until
something:WaitForChild("thiswillneverexist") --This yields the script until that exists
print("This will never run") -- Never will be ran
This is why it tells you that it can be yielded for an infinite amount of time.
@iiKossmoZ, It errors the second time because Frame is not set to the new frame after you respawn. This is why it indexes with nil and throws that error. Also, the same reason for the .Changed. It is looking for changed to a frame that does not exist after you respawn.
As I was using a coroutine to manage the loops, this operates outside of the Respawning?
I changed the ‘Loop’ to only apply if the Player’s Characters Health > 0 and it seems to have patched it! ^^