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

How to count certain objects that named Object2?

Asked by 4 years ago

I have model and In this model I have 10 objects that named "Object1". random of objects gonna have name "Object2". How I can count them all by using something like Model:GetChildren()

1 answer

Log in to vote
1
Answered by 4 years ago

First make a for loop and check they're names, then count along with a variable

Use this:

local count = 0

for i, v in pairs(model:GetChildren()) do
    if v.Name == "Object2" then
        count = count + 1
    end
end
0
I would reccomend using the # operator as the table can then be used later easily, if needed. Though this works perfectly fine as well. Benbebop 1049 — 4y
0
No, not like that. Without using + or -- ArtemVoronin0 171 — 4y
0
Object2 can back to Object1 ArtemVoronin0 171 — 4y
Ad

Answer this question