Infinite Yield possible on 'Workspace:WaitForChild("BoardList")' HOW?!

THE PART IS IN THE WORKSPACE!!!

local work = game:GetService("Workspace")
local Records = work:WaitForChild("BoardList")
local Up, Down = Records:WaitForChild("SurfaceGui"):WaitForChild("Up"), Records:WaitForChild("SurfaceGui"):WaitForChild("Down")
local ListFrame = Records:WaitForChild("SurfaceGui"):WaitForChild("PlayersList"):WaitForChild("List")
local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")

local MaxClicks = 50
local RecsClick = 0
local increment = .5
local strdeb = false

Up.MouseButton1Down:Connect(function()
	if rdeb then return end
	if RecsClick <= 0 then RecsClick = 0 return end
	RecsClick = RecsClick - 1
	rdeb = true
	ListFrame:TweenPosition(ListFrame.Position + UDim2.new(0,0,increment,0), "Out", "Quad", 2, true)
	wait(2.5)
	rdeb = false
end)

Down.MouseButton1Down:Connect(function()
	if rdeb then return end
	if RecsClick >= MaxClicks then RecsClick = MaxClicks return end
	rdeb = true
	RecsClick = RecsClick + 1
	ListFrame:TweenPosition(ListFrame.Position - UDim2.new(0,0,increment,0), "Out", "Quad", 2, true)
	wait(2.5)
	rdeb = false	
end)

What’s wrong with this? I don’t understand it’s saying the very second line is yielding for no reason at all.

Are you sure that you named it correctly? If it isn’t, then that’s why.

Tell me if I’m blind but this looks the exact same. Why’s it yielding?

Hm. That’s weird. I actually don’t know.

Oh I just tested in the game, apparently it’s getting removed something is removing it? What the…

That’s even weirder. Check through your scripts just incase. Otherwise maybe try remaking the part with a new name?

When you use the :WaitForChild() method of instances you need to consider the possibility that the thing you’re waiting for might never exist. Most of the time it should be there and ready to go almost instantenously.

In your case, I do agree that something could be deleting the board therefore causing an un-intended issue.

If you are anticipating the existence of an object and you have an incling as to how long it may take to exist, you can set a timeout on the :WaitForChild() method and respectively wait a set amount of time before continuing your code. As this does not wait forever, it will continue your current thread after the given time period and the variable you assigned with :WaitForChild() will either be nil (if the object did not replicate / appear in time) or be a reference to object you were waiting for.

1 Like

Thanks for the help, turned out the issue was I actually had StreamingEnabled on. I wasn’t aware of this, because I haven’t edited the game for a while so I forgot.

Ah yes, that makes total sense. StreamingEnabled can be a real hassle but the benefits to performance are fantastic.

Good luck with your project! :slight_smile:

1 Like