like for example:
i got the children of a player.
and i wanna know how many children he has but in a form of a number
how do i do something like that?
like for example:
i got the children of a player.
and i wanna know how many children he has but in a form of a number
how do i do something like that?
I’d personally use a for loop function that will gather the children and count up the variable:
local model = game.Workspace.MODEL_NAME
local parts = 0
for _, i in pairs(model:GetChildren()) do
parts = parts + 1
end
Hello. That’s a perfectly valid solution, but you could also use the length operator. GetChildren
returns a table, so you can call “#” on it to retrieve the length of the table, i.e. the number of children.
In your use case, it could look like this:
local num_of_children = #player:GetChildren()