I need to know for a game but I do not know if it is even possible
Is it possible to give a variable two values?
4 answers
Yes, it is possible using tables, example:
Values = {"abc", "cba"} -- etc, you can do as much as you want.
You can learn more about tables Here
local MyArray = {"Fun!", 123}
Arrays can do what you need. They can infact carry an infinite amount of bools, strings, and integers.
4 comments
aren't them called meta tables, or arrays lol? seems prety much the same
I dident know that there were metatables. I always called them arrays.
That's not a metatable, he doesn't know what he's talking about. That's just a table with an array-like structure.
Yap, so to not complicate stuff, an array is just a table, and you can say that an array is the general name of this "structure", because it is named differently in each language, in lua they are called tables while in python for example they are called lists. But even with those different names, they are still an array. And for metatables, ScriptGuider here does actually have a good video on them
local a, b, c = 1, 2, 3
print(a, b, c) --it will print '1 2 3'
print(a) -- it will print '1'
print(c, b) --it will print '3 2'
You get the point. Separate the Variable names by a comma, then separate the values by a comma and you will assign those values. There is also this method with tables:
local hi = {'hello', 3, 'stuff' }
but I don't really know how tables work so yeah. Sorry if this is not what you were looking for.
You can also do this
local gun = {}
gun.Damage = 100
gun.BulletSpeed = 1
print(gun.Damage)
it will print "100"
when referring to Damage just do gun.Damage when referring to BulletSpeed just do gun.BulletSpeed
of course you can change the names and add more
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
can you explain what those "abc" "cba" supposed to stand for? are they variables or location of what you wanted to lets say clone etc
Just random string values, you can use pretty much anything like numbers