I found this sigh from script on toolbox
Its been like this
local list = {}
for i=1,#list do
if list[i] == character.Name then
-- functions
end
end
I didn’t understand about # sigh
please someone explain about this
I found this sigh from script on toolbox
Its been like this
local list = {}
for i=1,#list do
if list[i] == character.Name then
-- functions
end
end
I didn’t understand about # sigh
please someone explain about this
It’s the length operator.
The length operator is denoted by the unary operator #. The length of a string is its number of bytes (that is, the usual meaning of string length when each character is one byte).
The length of a table t is defined to be any integer index n such that t[n] is not nil and t[n+1] is nil; moreover, if t[1] is nil, n can be zero. For a regular array, with non-nil values from 1 to a given n, its length is exactly that n, the index of its last value. If the array has “holes” (that is, nil values between other non-nil values), then #t can be any of the indices that directly precedes a nil value (that is, it may consider any such nil value as the end of the array).
Are you talking about the part where it says
for I=1,#list do
?
If so, the # just means the number of instances, variables, arguments, objects in the table list (returns the length of the table). So lf list = {"apples", "oranges", "bananas"}
then #list
would equal 3.
I recommend checking out this page for help with tables.
local players = game:GetPlayers()--get's table of players in game
print(#players)--prints how many players are in the game/the table
local aTable = {"a","b",1}
print(#aTable) -- This prints out 3, the length of the table.
# is the length or size operator. When used on a string it gets how many characters are in that string. When used on a table, specifically and only an array, it will get how many elements are in it.
You could have searched this up easily, this has been asked a million times before, search before posting.
You put # in front of an array if you want to know how much values it contains