Need help with checking whether a string has numbers, spaces, or abstract characters

I’m currently making a custom name chooser for players in my game. It prompt’s the player with a textbox and they get to type out the name they want, I don’t want them to be able to have spaces, numbers, or abstract characters in their name. So, how would I be able to detect this?

1 Like

You could do something like

function isValidName(name)
    return string.match("[%a%d]+") == name
end

string.match("[%a%d]+") finds the first occurence of a sequence of 1 or more characters that are either letters or numbers. That sequence is itself a valid name. If the whole name is the same as the matched sequence, then the whole name is a valid name.