Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

For i,v in pairs only loops once? [More letters because this wasnt a justifiable question?]

Asked by 1 year ago

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)

1 answer

Log in to vote
0
Answered by 1 year ago

yall r useless dev forum is better helped me :)

0
- Krektonix_Youtube 85 — 1y
1
sounds like you are the useless one who can't get anything to work by yourself greatneil80 2647 — 1y
1
skill issue virushunter9 943 — 1y
0
lmao you only waited for 1 day Kingu_Criminal 205 — 1y
Ad

Answer this question