Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How To Count Children Of A Specific Name?[Solved]

Asked by 5 years ago
Edited 5 years ago

So For Example, You Have Multiple Models Called "Jimmy", How To Count Them?

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Is this what you're talking about? (This is a regular script.)

num = 0
for _,m in pairs(game.Workspace:GetChildren()) do
    if m.ClassName == "Model" then
        if m.Name == "Jimmy" then
            num = num + 1
        end
    end
end

What this technically does is it stores a number that counts how many times the for loop detects a model named "Jimmy", and for every time there is a model named "Jimmy" the number gets 1 added to it. So if there were 6 models named "Jimmy" the number would be 6. It's actually pretty simple.

1
so simple this was almost a request. User#5423 17 — 5y
1
almost DeceptiveCaster 3761 — 5y
1
tyvm mkhamster 58 — 5y
Ad

Answer this question