How can I associate a letter with an int value?

For example, in ASCII “!” is 33 (which in binary is 100001). I wanna associate that string with the number 33. I tried doing

local ASCII = {
   "!" = 33
}

but I got an error obviously and I also can’t retrieve it from ASCII array. Does anyone else have an idea on how I can do this?

Roblox has built in functions to do this already.

string.byte("!") -- 33
string.char(33) -- !

Note that this is based off the extended ascii table. You can find one such copy here.

Also the reason your script errored was because you didn’t put brackets around the index. This should work:

local ASCII = {
   ["!"] = 33
}
print(ASCII["!"]) -- 33
3 Likes

Thank you! Never knew about this

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.