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

What does %# do, it just a curiosity question?

I've searched around the internet trying to figure out what %# does in the forms of lua or whatever, however I haven't been able to find a solid answer. What exactly does this do?

6 comments

0

Personally, I dont know, but perhaps its this? http://wiki.roblox.com/index.php/String_pattern

0

The hashtag could also mean the length of something. https://wiki.roblox.com/index.php/Operator

0

Sorry for the spam, but could you post the script?

0

There isnt a script, its just curiosity.

0

Dunno, if it's something like (5 % #lengthOfString), it means that is finding the remainder of the two values, see the wiki on operators for the #, sorry if I messed up, on mobile

0

Yea, it's like the <--, it's not a special thing, it's just two different symbols combined, in your case, the modulo and the length operator.

1 answer

✓ Accepted answer

Ok I will go over % the modulus operator then the other one you mentioned. What it does is it returns the remainder of a division problem. Here is an example:

local numberExample = 5 % 2
print(numberExample)

--> output is 1 because 5 /2 = 2 with a remainder of 1

the hashtag is a little more interesting. It will return the length of something. It can return the length of a string and a table and so on. Here is an example:

local tbl = {1, 4, 9, 2}
print(#tbl)
--> output is 4 because the table is four items long.

a really good answer on the modulus can be found here. I hope that I helped you out and have a great day scripting!

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