So I have a problem with my module script where is says there is a nil value I have tried going on the dev forum and looking it up, and just simply looking up the error but here is the script
P.S this is for a egg system
local petModule = {}
petModule.pets = {
["Epic"] = {game.ReplicatedStorage.pets.LavaBird};
["Rare"] = {game.ReplicatedStorage.pets.StereoPet};
["Uncommon"] = {game.ReplicatedStorage.pets.DodgeBall};
["Basic"] = {game.ReplicatedStorage.pets.BasicDoggo};
}
petModule.rarityTable = {
["Epic"] = 4;
["Rare"] = 16;
["Uncommon"] = 30;
["Common"] = 50;
}
petModule.chooseRandomPet = function()
local randomNumber = math.random(1,100)
local counter = 0
for rarity, weight in pairs(petModule.rarityTable) do
counter = counter + weight
if randomNumber <= counter then
local rarityTable = petModule.pets[rarity]
local chosenPet = rarityTable[math.random(1, #rarityTable)]
return chosenPet
end
end
end
return petModule
