Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is it possible to get the number of letters in a player's name?

plr = game.Players.LocalPlayer name = plr.Name

print() -- Number of letters in a player's name

1 answer

Names are a string, and strings can be manipulated in various ways. The easiest way to get the length of string is to use the string.len(str) function. It can be used two ways:

string.len("Hello World!")

("Hello World!"):len()

In order to get the length of the name of a player, simply do this:

plr = game.Players.LocalPlayer
print(string.len(plr.Name))

It's that simple!

For more information, click here: String Manipulation

3 comments

0

Very good answer.

1

A shortcut is the # unary length operator. #plr.Name is the same as plr.Name:len()

0

@Blue I never knew that, thank you.

This discussion is preserved as it was. New answers, comments, and votes are closed.