How to get only a few characters of a text value

Hello!

So I’m trying to make a car liscence plate script that makes unique liscence plates. using random generation would mean some innapropriate ones could be generated, and I’m not good enough of a scripter to include filtering for custom plates.
So I figure it would be best to use the first 3 characters of the players name and userID to create the plate id. For example, mine would be: RAN-514.

I’m able to get these values easily enough, (the UserId, and the player name) but the trouble I have is just with shortening the value. So I can get the player name, but I don’t know how to split the value to just the first three characters, so the ‘sal’ from ‘sally123’, or ‘123’ from ‘123457283’

Is there a way to split/shorten a value like this?

Thanks for any help, fonz.

1 Like

Use:

string.sub()

To find what you want in a string. For example I have “Amazing and cool Cats” so I will do

local message = "Amazing and Cool Cats"
print(message:sub(13, 21))

to get “Cool Cats”

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.