Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Cr0ws 20
9 years ago

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

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

1 answer

Log in to vote
3
Answered by 9 years ago

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

0
Very good answer. Grenaderade 525 — 9y
1
A shortcut is the `#` unary length operator. `#plr.Name` is the same as `plr.Name:len()` BlueTaslem 18071 — 9y
0
@Blue I never knew that, thank you. Spongocardo 1991 — 9y
Ad

Answer this question