Hello! So basically what I said above. I'm making a game and I have this partial regen system that spawns parts. I was wondering how I could put a limit to how many parts there are!
Here is my code:
local TrashSpawnArea = workspace.TrashSpawnArea
local Trash = workspace.Trash
local r = 255
while wait(1) do
local TrashClone = Trash:Clone()
local x,z = TrashSpawnArea.Position.X, TrashSpawnArea.Position.Z
x,z = math.random(x - r, x + r), math.random(z - r, z + r)
local pos = Vector3.new(x, TrashSpawnArea.Position.Y, z)
TrashClone.Parent = workspace
TrashClone.Position = pos
end
r would equal to the radius (or the area) that the parts spawn in. It's set to 255 because thats the default baseplate size.
This one is confusing to me, any help is appreciated!
p.s my script is in ServerScriptService
p.s.s don't mind me calling it trash lol

4 comments
Yes it is! Thanks! I will try this!
I'm guessing "if numb < 3 then" is the limit right?
Oh yea, sorry for the late reply ;-;
Also if you want the parts to delete themselves after a while, you could try coroutines (thought im not dure if this is the best solution)