Changing part of a name - String operations

Hey,

I’m currently trying to write a command whereby a player can change his “role” in a squad, which displays his roleplay name.

For Example: “James Jackson-01”

I want to create a command which would work like so:

/setrole 2

“James Jackson-02”

/setrole 5

“James Jackson-05”

The difficult part of this is that I need to have only the number changing in the name. From memory, I think I can use something about exploding a string, but I have absolutely no idea where to start with that.

Help is appreciated<3 If I haven’t made anything clear, please say!


string.format( "%s%-%02d", name, role )

Where Nick( ) is their base rp name ( James Jackson ) and role is the number. Would give results like

James Jackson-04
James Jackson-13

And so on