Error in Code that's still running?

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”)’



Limit:WaitForChild("Drop")["Planet"]["_Name"].Text = inRegion.Value
Limit:WaitForChild("Drop")["OwnedBy"]["Short"].Text = OwnedBy.Value

	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"
		Limit:WaitForChild("Drop")["Planet"]["Short"].Text = "-"

	Limit:WaitForChild("Drop")["OwnedBy"]["Short"].Text = Val2	
1 Like
  1. What is Limit?
  2. What is Drop?
  3. What is OwnedBy?
  4. Is this a LocalScript?
  5. Where is it? In StarterPlayerScripts?

Limit is a Frame,
Drop is a Frame,
‘OwnedBy’ is a string value,
This is a local script,
No, it’s a PlayerGui.

Share the code where you define Limit, please.

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.

Hope this helps! :smile:

@Ethanoj1 - Even without the :WaitForChild then I’m given the error message:
" Boundary is not a valid member of Frame "

[[ I changed ‘Limit’ to Boundary incase that was the error. It was not. ]]

Information = function()	
	UpdateInfo1(inRegion.Value); UpdateInfo2(OwnedBy.Value)

---- || ---- || ---- || ----
---- || ---- || ---- || ----

UpdateInfo1 = function(NewVal)
	Frame["Boundary"]["Drop"]["Planet"]["_Name"].Text = NewVal
	if NewVal == "Nevarro" then
		Frame["Boundary"]["Drop"]["Planet"]["Short"].Text = "NV"
	elseif NewVal == "Endor" then
		Frame["Boundary"]["Drop"]["Planet"]["Short"].Text = "EN"
		Frame["Boundary"]["Drop"]["Planet"]["Short"].Text = "-"

UpdateInfo2 = function(NewVal)
	Frame["Boundary"]["Drop"]["OwnedBy"]["Short"].Text = NewVal

Then “Boundary” is not a valid child of the “Frame” guiObject.

1 Like

Can assure ya, it is.

As said, it works fine when the Player first joins. But once respawn, that’s when the error is thrown.

Respawn, and see if the Boundary frame still exists inside the explorer.

Also, I’m pretty sure GUI’s are destroyed when you respawn so try checking if the humanoid is dead before updating.

The GUI is in StarterGui.
Could it be that I used a ModuleScript?

No that doesn’t matter as long as you use the functions of a ModuleScript correctly.

When you press reset, check the PlayerGui’s for your player and see if “Boundary” is still there.

1 Like

It is -
I changed my method from using .Changed to a while true loop - This seems to have fixed the issue. ._.

Uh, not sure… Hmm… Well see if it stays that way.

Sorry for the late reply.

@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.

The problem is wherever you’re defining these variables. You need to show where that’s happening.

Where does “Frame = ...” happen?

Where does “Limit = ...” happen?

@Ethanoj1 - I thought with it being a LocalScript within a StarterGui then it would re-assign upon Respawning?

@nicemike40 @Ethanoj1 - I think I found the issue.

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! ^^