i'm making some stupid brick factory game thing and i need to add a limit to how many bricks can be spawned at once (not in general) so i can avoid people lagging the server
you spawn bricks with the press of a button, anyway heres the script
local part = script.Parent
local h = 0.5
local ohno = 60
local db = false
part.ClickDetector.MouseClick:connect(function(player)
local bruh = Instance.new("Part", workspace)
bruh.Anchored = false
bruh.Position = game.Workspace.jeff.Position
bruh.Material = Enum.Material.Brick
bruh.BrickColor = BrickColor.Random()
bruh.Transparency = 0
bruh.Size = Vector3.new(2, 2, 2)
part.BrickColor = BrickColor.new("Really red")
wait(h)
db = true
part.BrickColor = BrickColor.new("Lime green")
wait(h)
db = false
wait(ohno)
bruh:Destroy()
end)
i'm thinking of doing an if statement but i was like nah

1 comment
i've already added a brick removal thing, line 21 and 22