I have a system set up which should print a list of 3 random packs. I don’t know why it’s not working. No errors but “Called” is not printing and this prints to the console: {
[1] = “Kakashi S1”,
[2] = “Naruto S1”,
[3] = “Sasuke S1”,
[4] = “Gaara S1”,
[5] = “Sakura S1”,
[6] = “Sasuke S1”
} - Server - CardManager:113
Script:
local Players = game:GetService("Players")
local PacksModule = require(script:WaitForChild("Packs"))
local Config = require(script:WaitForChild("Config"))
local ChosenPacks = {}
local function GetPack()
print("Called")
local pack = PacksModule.Packs[math.random(1, #PacksModule.Packs)]
if ChosenPacks[pack] then
GetPack()
else
table.insert(ChosenPacks, pack)
end
return pack
end
local function GetAllPacks ()
local NumberOfPacks = Config.Config["NumberOfPacks"]
for i = 1, NumberOfPacks, 1 do
GetPack()
end
print(ChosenPacks)
end
I’m not sure how PacksModule works, but there might be an issue with your condition checking for ChosenPacks[pack]. Try if table.find(ChosenPacks, pack) then instead.