local db = 1
local max = 50
local function SpawnThem()
for i, v in game.Workspace.Map:GetChildren() do
for n = 1, max do
local s = script.Coin:Clone()
s.Parent = game.Workspace.Coins[i]
local tel = v.Baseplate
s.Position = tel.Position - Vector3.new(math.random(0,tel.Size.X) - tel.Size.X / 2,-5,math.random(0,tel.Size.Z) - tel.Size.Z / 2)
s.Rotation = Vector3.new(0, math.random(0, 360), 0)
end
end
wait(0.1)
db = 1
end
SpawnThem()
local coins1 = game.Workspace.Coins["1"]
local coins2 = game.Workspace.Coins["2"]
local coins3 = game.Workspace.Coins["3"]
local coins4 = game.Workspace.Coins["4"]
local coins5 = game.Workspace.Coins["5"]
coins1.ChildRemoved:Connect(function()
if #coins1:GetChildren() < max / 5 then
for i, v in coins1:GetChildren() do
v:Destroy()
end
if db == 1 then
db = 0
SpawnThem()
end
end
end)
coins2.ChildRemoved:Connect(function()
if #coins2:GetChildren() < max / 5 then
if db == 1 then
db = 0
for i, v in coins2:GetChildren() do
v:Destroy()
end
SpawnThem()
end
end
end)
coins3.ChildRemoved:Connect(function()
if #coins3:GetChildren() < max / 5 then
if db == 1 then
db = 0
for i, v in coins3:GetChildren() do
v:Destroy()
end
SpawnThem()
end
end
end)
coins4.ChildRemoved:Connect(function()
if #coins4:GetChildren() < max / 5 then
if db == 1 then
db = 0
for i, v in coins4:GetChildren() do
v:Destroy()
end
SpawnThem()
end
end
end)
coins5.ChildRemoved:Connect(function()
if #coins5:GetChildren() < max / 5 then
if db == 1 then
db = 0
for i, v in coins5:GetChildren() do
v:Destroy()
end
SpawnThem()
end
end
end)
ErrorMessage: Maximum event re-entrancy depth exceeded for Instance.ChildRemoved (x4)

2 comments
Idk what you said but i added a debounce and it fixed everything but you can have an accept anyway
basically your destroying in a ChildRemoved function