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

How to see if something has children?

Asked by 7 years ago

So, I want to do an inventory. I have the most brilliant way to do it but, the way I am doing this requires a check to see if a slot has a child. I want to use an in pairs loop. So, how would I see if it has a child? I tried, if slot:GetChildren() == nil then , but that doesn't seem to work. Any help will be appreciated!!

1 answer

Log in to vote
1
Answered by 7 years ago

# Operator

for example:

model = workspace.Model --model in workspace
children = model:GetChildren() --getting children
if #children == 0 then --checking if number of children is equal to 0
    print(no children!) --or whatever you want here
end --ending the if statement

http://wiki.roblox.com/index.php?title=Table#More_information

Ad

Answer this question