Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make limited items in workspace?

Asked by 8 years ago

I know how to use the :findfirstchild instance in workspace but I'm trying to make it so that there can only be a maximum amount of a certain item. Like You've named a block Green and you've created a script that clones that brick and puts it in a random position. I'm trying to make it notice that there is 5 bricks named green and wait until there is less than 5 greens to spawn another?

1 answer

Log in to vote
0
Answered by
Decemus 141
8 years ago

You can do a for loop in this instance.
For example, you can do this:

local blocks = 0
for _,v in pairs(partname:GetChildren()) do -- This grabs all of the parts within the Instance and looks for the name.  If it finds the name, it will increase the amount of blocks.
if v.Name == Green then
blocks = blocks + 1
end
if blocks <= 5 then
--cloning part
0
Thank you Ill try that dustydevil12 0 — 8y
Ad

Answer this question