how to limit the maximum number of children?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lalel345

I have a grid container for an inventory and I want to limit its content to a specific number of children, how do I do it?

:bust_in_silhouette: Reply From: dustin

This is a simple solution.

if $Container.get_children().size > maximum_children:
     $Container.get_children()[-1].queue_free()