Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do i get the amount of children?

saw some guy sometime say that u could get the amount of children inside something using something like this code

for i,v in pairs(game.Players.LocalPlayer.PlayerGui:GetChildren()) do
		if v > 1 then
			print("more")
		end
	end

but all i get is an error, how would i make this work?

3 comments

2

When you make a for-loop, the variables you make are assigned to what the iterator returns (first = index and second = value). If you want to check how many children there are, just use the length of the table. print( #PlayerGui:GetChildren() ). The # operator gets the length of the expression (in a table's case: the amount of fields)

0
0

making it into a local variable got me there, thanks

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.