Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 1 year ago

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????

1
Try using "FindFirstChild" instead SerpentineKing 3880 — 1y
0
I also attempted that but had the same issue CrazyCorrs 98 — 1y
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 SerpentineKing 3880 — 1y
0
It isn't nil though I manually put it there that's what is confusing me? CrazyCorrs 98 — 1y
0
Plus it works sometimes, so it must be there CrazyCorrs 98 — 1y

1 answer

Log in to vote
1
Answered by
AIetheo 236 Moderation Voter
1 year ago

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

0
I'll try this, thanks! CrazyCorrs 98 — 1y
0
This seems to just skip it now? I kinda need it to remove but now this just doesn't do anything CrazyCorrs 98 — 1y
Ad

Answer this question