Changing part of a name - String operations


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!

EDIT: Got it by doing

local choice = arguments[1]
local parts = string.Explode( “:”, player:Name() )
local newname = choice … “:” … parts[2]