Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make limited items in workspace?

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

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

1 comment

0

Thank you Ill try that

This discussion is preserved as it was. New answers, comments, and votes are closed.