Issues with InPairs for a ping system

I am trying to make a game called Scoobis Containment. It’s turning out really well, but it’s extemely difficult because the win condition can’t be tracked. My solution: the Orb Finder!
Whenever you use the Orb Finder, every orb on the map gets ‘pinged’ making them display a BillboardGUI that can be seen through walls.
However, the pinging system has an error with my in pairs(). I have no clue how to use in pairs() because nobody has really made a good tutorial on how to run through a list using it.

local debounce = false
local orbsthatexist = script.Parent:GetChildren("Part")

script.Parent.Activated:Connect(function()
	if debounce == false then
		debounce = true
		script.Parent.Name = "Orb Finder [COOLDOWN]"
		game.Workspace.Ping:Play()
		
		for i, orb in pairs(orbsthatexist) do
			orb.Ping.Enabled = true
		end
		
		wait(7)
		
		for i, orb in pairs(orbsthatexist) do
			orb.Ping.Enabled = false
		end
		
		wait(60)
		debounce = false
		script.Parent.Name = "Orb Finder"
	end
end)

If you want to play the game for yourself, here is the link:

Currently the script fails at the first in pairs().

1 Like
local debounce = false
local orbsthatexist = script.Parent:GetChildren()

script.Parent.Activated:Connect(function()
	if debounce == false then
		debounce = true
		script.Parent.Name = "Orb Finder [COOLDOWN]"
		game.Workspace.Ping:Play()
		
		for i, orb in pairs(orbsthatexist) do
            if orb:IsA("Part") then   
				orb.Ping.Enabled = true
			end
		end
		
		wait(7)
		
		for i, orb in pairs(orbsthatexist) do
			if orb:IsA("Part") then   
				orb.Ping.Enabled = false
			end
		end
		
		wait(60)
		debounce = false
		script.Parent.Name = "Orb Finder"
	end
end)
1 Like

Oops! I figured out the problem. OrbsThatExist is not in script.Parent. LOL, I’m going insane from programming this game. Thanks for your help though.