for i, part in pairs:GetChildren() do
currentAmount = currentAmount + 1
end
When I execute this code in a script inside workspace, I get the next error in the console:
Workspace.Script:4: attempt to index global ‘pairs’ (a function value)
What does it mean and how can I solve it?
:GetChildren is a method of instances. An instance are things like parts, models, scripts and other stuff. So GetChildren cannot be used on pairs. Your code should look something like:
for i, part in pairs(theNameOfTheModel:GetChildren()) do
currentAmount = currentAmount + 1
end
This would go through every child inside of the model you have defined. You should also post your updated code so we could see what you’re doing.