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

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

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

yall r useless dev forum is better helped me :)

4 comments

0
1

sounds like you are the useless one who can't get anything to work by yourself

1

skill issue

0

lmao you only waited for 1 day

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