How to rename parts according to how many of them?

Here’s something I did, well it renames it but not in order.

local totalPlates = #script.Parent:GetChildren()

for i, plates in pairs(script.Parent:GetChildren()) do
	plates.Name = math.random(1, totalPlates)
	print(plates.Name)
	
end

image

You are setting the name to a random number, when you can set the name to the index.

local totalPlates = #script.Parent:GetChildren()

for i, plates in pairs(script.Parent:GetChildren()) do
	plates.Name = tostring(i)
	print(plates.Name)
	
end
1 Like

Thank you so much for helping me!!

1 Like