hi guys i’m making a game where i have to save some rarities that a player has unlocked, for example, playerA has common, rare and epic;
what would be the best way to save it?
For some other systems i sometimes have to check if a player has a rarity, so I’m undecided between this 2 types of tables:
--type 1
local myTable = {
common = true,
rare = true,
epic = true
}
or
-- type 2
local myTable = {
"common",
"rare",
"Epic"
}
probaly the type2 could have less problems but to search a rarity i have to iterate all the table to search it, with the type1 i could just use FindFirstChild
oh yeah sorry i didn’t read the “probaly the type2 could have less problems but to search a rarity i have to iterate all the table to search it, with the type1 i could just use FindFirstChild”
For the 1st one you’d do: myTable[SOMETHING] or myTable.SOMETHING
while for type 2 you’d do something like: table.find(myTable, SOMETHING) or myTable:find(SOMETHING)
The first one is a dictionnary while the 2nd one is an array, to check rarity in that case, I’d rather use the first one as I believe it is easier to do if myTable.rare than than if myTable:find("rare") then but both will lead to the same result, the 2nd one is like saying: [1] = "common", [2] = "rare" , [3] = "Epic"
(btw, you put a capital E for type 2, be careful if you’re using this in an actual script)