If Any Children

How would I find out if a Model has ANY children at all without checking for a specific name?

For example,

if game.Workspace:FindFirstChild("Storage") has children then
  print("Storage has kids!")
else
  print("Storage ain't got no kids.")
end
if #instance:GetChildren() > 0 then
   -- Do something
end

EDIT:

For clarity, the # operator returns the number of instances in a numerically indexed table. The :GetChildren() function retrieves a table of all children inside an instance.

3 Likes
if #workspace:FindFirstChild("Storage") :GetChildren() > 0 then
  return true
else
  return false
end
1 Like

object:ClearChildren() ight work for something

1 Like

Is that necessary? That can boil down to

return #workspace.Storage:GetChildren() > 0
1 Like

That removes all children of the instance and you got the name of the function wrong, it’s :ClearAllChildren()

Awesome! Thank you everybody! :slight_smile:

well as this would use a much more complex script as if it can clear children

What are you trying to say exactly, I couldn’t understand anything from that sentence no offense.

nvm
characterrrrrrrrrrrrrrrrrrrrrs