sub chops up the string into two parts, given by its parameters. The first parameter decides where it begins the section, and the second parameter decides where it ends the section.
For example...
example = "test"
print(example:sub(1, 2))
print(example:sub(2, 4))
print(example:sub(2))
Notice in the last example that when you leave out the second parameter, it just gives you the rest of the string!
Now, you can use sub for what you're aiming for. However, I personally would use find instead. Why? Because find can tell me where a certain string begins and ends. In this case, I want to know where the string "/" ends because I know after that string there will be a player name I can work with!
So here's an example...
example = "kill/Greatgreatgood5"
print(example:find("/"))
Notice that find returns two things; the index of where "/" began and where "/" ended. Now that we know the index of where "/" ended, we can try to get the rest of the string using sub!
Here's how that would look...
example = "kill/Greatgreatgood5"
start, finish = example:find("/")
print(example:sub(finish + 1))
Notice that I used finish + 1 as the only parameter in sub; this is because we want to chop off the "/" that we found using find! Now, using the string we get from example:sub(finish + 1), we can find the player we were looking for by looping through all of the players.
example = "kill/Greatgreatgood5"
start, finish = example:find("/")
playerName = example:sub(finish + 1))
for _, player in pairs(game.Players:GetPlayers()) do
if player.Name == playerName then
print("Found!")
break
end
end
Extension
What if we had only a chunk of the player's name? How would we find that player? Well, we'd just employ find once more and check whether or not it returns nil; if find cannot find the pattern its given in its parameter, it will return nil!
example = "kill/greatgood"
start, finish = example:find("/")
playerName = example:sub(finish + 1))
for _, player in pairs(game.Players:GetPlayers()) do
if player.Name:lower():find(playerName:lower()) ~= nil then
print("Found!")
break
end
end