I am making a game like Miners Haven, and I am having quite some trouble making a clear ore system. Basically, I have all of my ores in a certain folder, which I get using folder:GetChildren(), and put that in a for i,v in pairs loop and do v:Destroy() to get rid of them all. However, no matter how many ores there are in the folder, it will only destroy one ore.
I don’t know if I’m missing something or just being stupid, so if you want the code, here it is, but beware, it’s a bit janky:
local deb = 0
script.Parent:WaitForChild("Model"):WaitForChild("Middle"):WaitForChild("ProximityPrompt").Triggered:Connect(function(player)
local children = script.Parent.Parent.Parent:WaitForChild("MiscInfo"):WaitForChild("OresDropped"):GetChildren()
if player.Name == script.Parent.Parent.Parent.Owner.Value then
if deb == 0 then
deb = 1
print(#children) -- This returns how many ore is in the folder, I've had values of 5 in the output but yet again it only destroys one of the ore at a time.
print("Passed Children")
for i,v in pairs(children) do
print(i,v)
v:Destroy()
deb = 0
end
end
end
end)
As I said it’s none of those things. You could also know that as I put 4 .parents in and only went down twice. So not the same folder, and I’ve already said there were multiple ores in the folder.
Just wait a moment, that was for testing not recommended as a permanent solution…
If the loop is yielding, you’d better checking what is the issue causing it to yield.
Oh wow!!! I removed all variables of debounce and the debounce check and it also worked. Debounce had nothing to do with the loop though? Is that an actual roblox bug lol?