Is there a way to get a number of children there is in a model? I want this to print 'Limit is not reached' or 'Limit is reached' depending if there are more than 10 children in a model or not. I tried doing this =D and when I was looking if someone else had this problem in forum I couldn't find the solution:
script.Parent.ClickDetector.MouseClick:connect(function(Player) if script.Parent:GetChildren()<10 then print'Limit is not reached' elseif script.Parent:GetChildren()>=10 then print'Limit is reached' end end)
Error: Workspace.Model.Script:2: attempt to compare table with number
Help pls.
You can use the '#' operator.
script.Parent.ClickDetector.MouseClick:connect(function(Player) if #script.Parent:GetChildren() <10 then print'Limit is not reached' elseif #script.Parent:GetChildren() >= 10 then print'Limit is reached' end end)