fastslug08
(FastTheDev)
November 2, 2021, 4:06am
1
Hello, i was recently wondering how i could make a script that totals all the parts in the workspace with a specific name
for example it can be used to show the number of parts called “table” in a gui text label on the players screen
I plan to use this to calculate a percentage of objects that have been deleted or missing.
local count = 0
for i, v in pairs(workspace:GetDescendants()) do
if v.Name == "" then --change to name of part
count += 1
end
end
print(count)
1 Like
fastslug08
(FastTheDev)
November 2, 2021, 5:33am
3
Thank you very much. Ill use this right away, and let you know how it worked out!
fastslug08
(FastTheDev)
November 2, 2021, 6:17am
4
also, i was wondering where i should put this script?
local count = 0
for i, v in pairs(workspace:GetDescendants()) do
if v.Name == "" then --change to name of part
count += 1
end
end
script.Parent.Text = "Number of parts: "..count
This would work as a local script if placed inside the TextLabel.
1 Like