Okay so, I have a system that pulls random cards from a list of arrays that vary from rarities (common, uncommon, etc.). The cards all have a list of values specified like the name, rarity, chance, color, etc., and are assigned mostly the same values (only difference being the name/title, and different rarities every few cards)
It works just fine, but for some reason the table will only pick the first card from the “common cards” section and completely skip over the rest. I have multiple cards in the other sections (6 in basic for example) and it includes all of them so far. All of the cards in common are formatted the exact same, yet only the very first card in that specific section will work and I don’t understand why.
I’ve been looking for like 2 days for a solution but I can’t seem to find any posts that have this kind of problem. I’ve tried lowering the amount of cards in the section, or rearranging them, and even rewriting all of the values, but nothing seems to work.
Here’s the table of the cards & an example of what all of the values are. Again, every section works fine, but it skips all of the arrays in between “Bloo” and the first basic card.
--Name[1], Rarity[2], Chance[3], Color[4], TextColor[5], Font[6], Image[7], Desc.[8]
return {
------------------------------------------------------------------------------------------------------ Common
{"Bloo", "Common", common.Chance, common.Color, common.TextColor, common.tFont, nil, nil};
{"Milo", "Common", common.Chance, common.Color, common.TextColor, common.tFont, nil, nil};
{"Nicole", "Common", common.Chance, common.Color, common.TextColor, common.tFont, nil, nil};
{"Troy", "Common", common.Chance, common.Color, common.TextColor, common.tFont, nil, nil};
{"Will", "Common", common.Chance, common.Color, common.TextColor, common.tFont, nil, nil};
{"Troy", "Common", common.Chance, common.Color, common.TextColor, common.tFont, nil, nil};
{"Dione", "Common", common.Chance, common.Color, common.TextColor, common.tFont, nil, nil};
{"Peter", "Common", common.Chance, common.Color, common.TextColor, common.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Basic
{"Jenna", "Basic", basic.Chance, basic.Color, basic.TextColor, basic.tFont, nil, nil};
{"Zackary", "Basic", basic.Chance, basic.Color, basic.TextColor, basic.tFont, nil, nil};
{"Clint", "Basic", basic.Chance, basic.Color, basic.TextColor, basic.tFont, nil, nil};
{"Evelyn", "Basic", basic.Chance, basic.Color, basic.TextColor, basic.tFont, nil, nil};
{"Nikki", "Basic", basic.Chance, basic.Color, basic.TextColor, basic.tFont, nil, nil};
{"AE.1", "Basic", basic.Chance, basic.Color, basic.TextColor, basic.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Uncommon
{"IceCream Guy Ky", "Uncommon", uncommon.Chance, uncommon.Color, uncommon.TextColor, uncommon.tFont, nil, nil};
{"Kylo Jr.", "Uncommon", uncommon.Chance, uncommon.Color, uncommon.TextColor, uncommon.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Rare
{"Cameron", "Rare", rare.Chance, rare.Color, rare.TextColor, rare.tFont, nil, nil};
{"Lila", "Rare", rare.Chance, rare.Color, rare.TextColor, rare.tFont, nil, nil};
{"Charmaine", "Rare", rare.Chance, rare.Color, rare.TextColor, rare.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Ambitious
{"Matthew", "Ambitious", ambitious.Chance, ambitious.Color, ambitious.TextColor, ambitious.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Face Card
{"Kylo", "Face Card", face.Chance, Color3.fromRGB(21, 125, 30), face.TextColor, face.tFont, nil, nil};
{"Blu", "Face Card", face.Chance, Color3.fromRGB(12, 28, 176), face.TextColor, face.tFont, nil, nil};
{"Asher", "Face Card", face.Chance, Color3.fromRGB(152, 8, 8), face.TextColor, face.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Epic
{"Dr. Zoe", "Epic", epic.Chance, epic.Color, epic.TextColor, epic.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Legendary
{"Phrog Blu", "Legendary", legendary.Chance, legendary.Color, legendary.TextColor, legendary.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Special
{"Blooming Kylo", "Special", special.Chance, Color3.fromRGB(74, 204, 67), special.TextColor, special.tFont, nil, nil};
{"Halloween Blu", "Special", special.Chance, Color3.fromRGB(255, 85, 0), special.TextColor, special.tFont, nil, nil};
{"Halloween Kylo", "Special", special.Chance, Color3.fromRGB(255, 85, 0), special.TextColor, special.tFont, nil, nil};
{"Halloween Asher", "Special", special.Chance, Color3.fromRGB(255, 85, 0), special.TextColor, special.tFont, nil, nil};
---------------------------------------------------------------------------------------------------- Prestigious
{"???", "Prestigious ", prestigious.Chance, prestigious.Color, prestigious.TextColor, prestigious.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Mythical
{"Mono", "Mythical", mythical.Chance, mythical.Color, mythical.TextColor, mythical.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Elite
{"???", "Elite", elite.Chance, elite.Color, elite.TextColor, elite.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Ultimate
{"???", "Ultimate", ultimate.Chance, ultimate.Color, ultimate.TextColor, ultimate.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ Liminal
{"deth!Kylo", "Liminal", liminal.Chance, liminal.Color, liminal.TextColor, liminal.tFont, nil, nil};
--------------------------------------------------------------------------------------------------- Transcendent
{"The Eternal & Divine", "Transcendent", transcendent.Chance, transcendent.Color, transcendent.TextColor, transcendent.tFont, nil, nil};
---------------------------------------------------------------------------------------------------- Masterpiece
{"deth!Blu", "Masterpiece", masterpiece.Chance, masterpiece.Color, masterpiece.TextColor, masterpiece.tFont, nil, nil};
------------------------------------------------------------------------------------------------------ .........
}
This is the script I use to pull a random array/card from the table.
return {
getRandomIndex = function(chances)
for i, v in ipairs(chances) do
local randomNum = math.random(1, v[3])
if randomNum == 1 and v[3] > chances[1][3] then
return {
v[1];
v[2];
v[3];
v[4];
}
end
end
return chances[1]
end,
}
Here’s a video of the “pulling/gacha” mechanic. I’ve tested this multiple times and it always ends up the same: I barely get any common cards, and when I do it’s always that singular card and none of the other ones, and I doubt I’m just really really unlucky.
I’m really looking forward to polishing up this game and finally adding more core elements to it, but I really can’t progress with this problem in the way. Thanks for any help! ![]()