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
I have a solution (sorta). So you could put a value and add to it every time a clone spawns, and then have an if then for the amount of times the thing spawns.
local TrashSpawnArea = workspace.TrashSpawnArea local Trash = workspace.Trash local numb = 0 local r = 255 while wait(1) do if numb < 3 then local TrashClone = Trash:Clone() TrashClone.Name = "TheName=/" 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 numb = numb + 1 end end
Hope this is what you were looking for! Also I'm guessing TrashSpawnArea is a transparent block above the baseplate?