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

Can someone help me with this bug which is effecting me majorly?

Hello. I have made a script which is meant to remove a house when a player leaves or types a command. I made this a function. This seems to work fine but whenever around 8 people start playing I get this error saying "Infinate yield possible on". This is really annoying because I know for a fact it's there and I keep getting these errors... Heres my script

function remove(booth)
	for i, child in ipairs(game.ReplicatedStorage.Information:GetChildren()) do
		if child:WaitForChild("Plot") then
			if child.Plot.Value == booth.Floor.Floor then
				child:Destroy()
			end
		end
	end
end

This works sometimes????

5 comments

1

Try using "FindFirstChild" instead

0

I also attempted that but had the same issue

0

Can you use a "print(i, v)" on the table to see if anything is nil? ipairs will stop the function if it returns nil

0

It isn't nil though I manually put it there that's what is confusing me?

0

Plus it works sometimes, so it must be there

1 answer

✓ Accepted answer

My first guess is that its because you used ipairs which stops once it finds a nil arguement, and that you used WaitForChild instead of FindFirstChild.

function remove(booth)
    for i, child in pairs(game.ReplicatedStorage.Information:GetChildren()) do
        if child:FindFirstChild("Plot") then
            if child.Plot.Value == booth.Floor.Floor then
                child:Destroy()
            end
        end
    end
end

2 comments

0

I'll try this, thanks!

0

This seems to just skip it now? I kinda need it to remove but now this just doesn't do anything

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