Help with spawning part at a fixed interval properly

I’m trying to spawn a part at a fixed interval, as the title says. The spawner on the right is working properly, however the left spawner is spawning two at a time. I’ve tried debounce among various other things, however it still behaves the exact same.

local debris = game:GetService("Debris")
local runservice = game:GetService("RunService")
local a = 5
local v = 15
local t = 60
local c = Color3.fromRGB(227,222,245)
local cpp = {0.6,0.05,0,1,1}
local pt = "Part"
local b = 0

runservice.Heartbeat:Connect(function()
	if b <= 0 then
		b = a
		if script.Parent.Parent.Parent.Name == script.Parent:GetAttribute("Tycoon") then
			local dropper = script.Parent.Dropper
			local p = Instance.new(pt)
			p.Size = dropper.Size
			p.Position = dropper.Position
			p.Color = c
			p.Material = Enum.Material.Ice
			p.CustomPhysicalProperties = PhysicalProperties.new(cpp)
			p.Parent = script.Parent.Parent.Parent.Debris
			p:SetAttribute("Value", v)
			debris:AddItem(p, t)
		end
	else
		b = b - 0.01
	end
end)

^ This is the code for both of the spawners.

1 Like