What does the # mean?

When scripting, I see a lot of people write like #map or like #players in scripts. I’m wondering what does that # mean? Why is it useful and when should I use it?

1 Like

The length operator.

Gives the length of a string or table.

3 Likes

As @nicemike40 mentioned, it’s basically to get the length of something

Exampels

local name = "John"
print(#name) -- Prints 4 since there are 4 characters
local tbl = {"Apple","Pear","PineAPple"}
print(#tbl) --Prints 3 since are the 3 entries in the table

It gives the length of a table, or what @nicemike40 said, a string. Basically, if there was a part with 5 children, running print(#workspace.Model:GetChildren() would print 5.

It basically just gives the length of something:

local players = game.Players:GetPlayers()
print(#players) -- prints how many players there are

or

local tbl = {"Apple", "Orange", "Bannana"}
print(#tbl) -- 3

counting the number of the total values on a table