Hi, my name is Sandessat and what # means in lua, what does it do??
Example:
Hi, my name is Sandessat and what # means in lua, what does it do??
Example:
In this instance # means number of children.
#
is the length operator in Lua. It returns the count of how many objects there are in an array. In this case, it returns the number of how many children in an instance there are. You can use this for tables.
Oh okay.
TAGS: Heart button is not working…
Better explanation, thank you!!!
This is probably useful in the future, if you come across any Lua operators that you don’t recognize: (at least for roblox)
The #
operator works on strings too!
Example:
local str = "Hello!"
print(#str) --6
It’s identical to string.len()
.
you can use # for calculating the total count as @DesiredFlamingFire also mentioned like :
local Players = Game:GetService("Players")
local allofthem = #Players:GetPlayers()
print(allofthem.."Player(s) in the game")
#table will get the ammount of keys/entities inside of that table.
#object:GetChildren() is returning a table. Were simply counting the contents. So.
Etc
Table = {1, 2, 3, 4, 5, “Hi”}
#Table – returns 6 because we have 6 items kn our table.
Next time you post something on the DevForum try searching for the solution on Google and check if maybe your question was asked before on the forum.
3 seconds of google search and I found the documentation of Lua describing the # operator.
http://www.lua.org/manual/5.1/manual.html#2.5.5