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

How would I give a Part an ID depending on its name?

Title sounds confusing, I know. But here's the thing.

I have a folder filled with Parts. Those parts have names from 1 to 35. So for example: grid1, grid2, grid3, grid4... So how would I take that number from its name and put it in a NumberValue?

Screenshot of explorer

1 answer

✓ Accepted answer

I would do it like this, maybe there is better way but this one works as well:

local part = script.Parent
print(string.sub(part.Name, 5, #part.Name))

well so string sub subs it yeah and #part.Name means how much letters does name have, the number 5 means how much letters before that number, it must be on 1 higher so example:

cube = 5 car = 4

Hope i explained it right tho

1 comment

0

Thank you! You led me to the right track!

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