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

How do I go through a number ordered model and rename the children to also be number ordered?

I have the InCommand plugin to make my life easier but in a power user way but there's something I've never been tought to (I learned scripting through youtube tutorials) and that is... going through loops and doing things to make it ordered by adding an incremental number at the end.

so, I use a temporary script to check if there's any problems and there was but I fixed it and, it still didn't work because I literally don't know how to do that kind of thing, I was never tought that.

Script:

local model = workspace.ServerRoom

for i = 1, 16, 1 do
	for k, v in pairs(model["ServerPack"] .. i:GetChildren()) do
		for j = 1, 10, 1 do
			v.Name = "Box" .. j
		end
	end
end

Error: Runtime error in InCommand script: ServerPack is not a valid member of Model "Workspace.ServerRoom" (x2) - Studio

3 comments

0

Is there an instance named ServerPack in ServerRoom?

0

yes, it's a model. They're all manually number ordered. (What I mean by "manually" is I renamed them in studio)

0

it's basically like this: ServerPack1 ServerPack2 ... etc

1 answer

✓ Accepted answer

Found the issue. So basically this:

model["ServerPack"] .. i:GetChildren()

would be like saying

model.ServerPack..i 

which would result in an error but since ServerPack Doesn't exist it created this error:

Runtime error in InCommand script: ServerPack is not a valid member of Model "Workspace.ServerRoom" (x2) - Studio

So if you move the '..i' into the brackets it should work as normal.

model["ServerPack"..i]:GetChildren()

9 comments

0

Thanks!

0

Well, it did fix the problem but now, How do I make it to number order it for me? for example: Box1 all the way to Box10

0

Because I am so new to for loops (except for for i, v in pairs loops)

0

It didn't number it?

0

seems like it should work

0

I mean it can rename all children, but all of them is going to be the same name as the first one

0

I want the number to be incremental, not the same name for every other child.

0

Remove the 'for j = 1, 10, 1 do' and change 'v.Name = "Box" .. j' to 'v.Name = "Box" .. k' and that should work.

1

TYSM It works perfectly as expected now! lemme save that script so it'd take less time in the future! :))

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