Still have questions? Join our Discord server and get real time help.
0

# How do you see how many parts are in an game?

i want to make a TextLabel that lets you see How many parts are in an game . is it even POSSIBLE?

0

Yes, this is in fact possible. The way you could do this is to create a table containing all the parts found. For this to work, simply redefine the text label that you want to show the part count in.

local textLabel = script.Parent
local parts = {}

for a, b in pairs(game:GetDecendants()) do
if b:IsA("Part") then
table.insert(parts, #parts, b)
end
end

textLabel.Text = #parts

0
SirGamezy 152
3 days ago

Yes, it's possible. Here's how:

Getting Literally Everything

game:GetDescendants()


This gets everything in the game and creates a table with the items. To get the length of the table, do:

local myTable = game:GetDescendants()
local myTableLength = #myTable


To get everything in the workspace, simply change it to game.Workspace:GetDescendants()

Getting All Parts

To get all parts, simply create a loop:

local myTable = {}

for _,obj in pairs(game:GetDescendants()) do
if obj.ClassName == "Part" then
table.insert(myTable, obj.Name)
end
end

local myTableLength = #myTable


Like the other example, you can simply replace game:GetDescendants() to game.Workspace:GetDescendants() to get all parts in the workspace.