If I understand you correctly, you want a table structure like:
TwitterCodes
?Testificate
??# of coins
??# of gems
?Test
??# of coins
??# of gems
?abcdef
?# of coins
?# of gems
but you want each element on one line. This can be done:
local TwitterCodes = {
Testificate = {Coins = #, Gems = #},
Test = {Coins = #, Gems = #},
abcdef = {Coins = #, Gems = #},
}
I think your main issue is you misunderstand how tables work.
A table is a list of entries, having an index and a value
| index |
value |
| 1 |
"value1" |
| 2 |
"value2" |
an index can be a string or a number. A value can be anything, including another table.
Lets take a look at how they are constructed.
First of all a string indexed table
local strTable = {
strIndex = "value",
strIndex2 = "value2"
}
local strTable2 = {
["strIndex"] = "value",
["strIndex2"] = "value2"
}
| index |
value |
| "strIndex" |
"value" |
| "strIndex2" |
"value2" |
strTable and strTable2 are exactly the same, just two different ways of making string indexes
these can also be done on one line
local strTable = {strIndex = "value", strIndex2 = "value2"}
local strTable2 = {["strIndex"] = "value", ["strIndex2"] = "value2"}
and you can have a value be a table
local strTable = {table = {subtable = "value"}}
local strTable2 = {["table"] = {["subtable"] = "value"}}
if there is any confusion ask and I'm happy to elaborate.
#Edit
I saw the code you posted and I think I understand. You want the first value to be the name of the second value. I don't see why this is necessary, keep the table that I showed you and just do:
local AmountToGivePlayer = TwitterCodes[Code].Coins
local LeaderboardValue = Player.leaderstats.Coins
instead.
7 comments
I understand now, thank you so much!
local TwitterCodes = { Testificate = {Coins = #, Gems = #}, -- Code 1 Test = {Coins = #, Gems = #},-- Code 2 abcdef = {Coins = #, Gems = #},-- Code 3 } doesnt seem to be working ;/
I saw the code you posted and edited my answer.
if i just put coins on Local AmountToGivePlayer = TwitterCodes[Code].Coins? wont it only give me coins?
@TSSRafa do the same for gems, just replace coins with gems
could you explain a bit further i'm having trouble understanding exactly what you want me to do.
Nevermind! i figured it out lol