Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make each part seperate names??

ok heres what i want the script to do i want it to go threw the model i set it to and change each parts name basically i want each part to have a different name 1-100

--[script]--
wait(4)
a = 0
part = game.Workspace.test:GetChildren()


for i = 1,100 do
	wait()	
	a = a + 1
	local rp = part[math.random(1,#part)]
b = game.Workspace.test:FindFirstChild(rp.Name)
if rp.Name == b then
	
else
	rp.Name = a
end	


	
end

2 comments

0

Please put your code in a code block. Click the Lua button and put your code between the lines

0

First of all, edit your question, click the little blue Lua button, and put your code between the lines.

1 answer

✓ Accepted answer

Hello, your title is a bit misleading... but I think I understand what your asking. If not, then just let me know and I can answer it more accurately (:

I am not sure if this website allows us to just GIVE the answer away, So I will put comments indicating what some of the lines do.

Coding :

local contains = function(tab, mat) --takes in a table and to be matched value
for i, v in pairs(tab)do
if(v == mat)then
return true
end
end
return false
end

local randomize = function(model) --takes in path to model

local children = model:GetChildren()
local amount = #children

local used = {}

for i=1, amount do
local index = math.random(1, amount)
repeat index = math.random(1, amount) until not contains(used, index)
children[index].Name = i -- or children[i].Name = index
end

end

....After coding all of that I just realized something ...

I could have just did :

local function func() --[[code]] end

qq oh well, PM me if you need additional help (:

This discussion is preserved as it was. New answers, comments, and votes are closed.