I have a question:
how to limit folder Items?
for example:
I want to have a folder with MAX 10 Items not more(no more can get into that folder)
can i do
`
Folder:GetChildren() <= 10
`
thanks for help
I have a question:
how to limit folder Items?
for example:
I want to have a folder with MAX 10 Items not more(no more can get into that folder)
can i do
`
Folder:GetChildren() <= 10
`
thanks for help
local ItemsInFolder = #workspace.Folder:GetChildren() --This actually returns back the number of the items inside the Folder
print(ItemsInFolder)
if ItemsInFolder >= 10 then
--Do something here
end
You can use the #
operator, which returns back the amount of things inside the table
Just don’t put another thing in it if there’s already 10?
but how can i limit that if i make instanse new part and i don’t want to stop it instansing just stop untill there will be space
It depends how you want to do this, if you are putting things into this folder and want to make a limit eg cloning yes you can do if #Folder:GetChildren() < 10 however if it’s overall you will have to find new children, which you can do
Folder.ChildAdded:Connect(function(Child)
if #Folder:GetChildren() > 10 then
wait(0.1) --Should stop an error like: Something unexpectedly tried to set the parent of Part to NULL while trying to set the parent of
Child:Destroy()
end
end)
your question is confusing explain more @artum669
For count how much models/Items/etc have, u need use the #
, its the most easy mode, and the only one (I know)
local Items = workspace.Folder:GetChildren() --This actually returns back the number of the items inside the Folder
print(#Items)
if #Items >= 10 then
print("Its working, it have ".. #Items.. "items")
end
I hope to be of help to you