this a server script
game.Players.PlayerAdded:Connect(function(plr)
wait()
local module1 = require(script.Parent.PetModule)
local pet = module1.chooseRandomPet()
print(pet.Name.." Selected")
end)
and this is the module
local petModule = {}
petModule.pets = {
["Secret"] = {
game.ReplicatedStorage["Pet Storage"].Ctulu;
};
["Legendary"] = {
game.ReplicatedStorage["Pet Storage"]["Shadow Dominus"];
};
["Epic"] = {
game.ReplicatedStorage["Pet Storage"].Ultimus;
};
["Rare"] = {
game.ReplicatedStorage["Pet Storage"].Reaper;
};
["Uncommon"] = {
game.ReplicatedStorage["Pet Storage"]["Demon bee"];
};
["Common"] = {
game.ReplicatedStorage["Pet Storage"].Pumpkin;
};
}
--weighted selection
-- 100 total wight
petModule.rarities = {
["Secret"] = 0.1;
["Legendary"] = 2.9;
["Epic"] = 8;
["Rare"] = 18;
["Uncommon"] = 30;
["Common"] = 41;
}
petModule.chooseRandomPet = function ()
local randomNumber = math.random(10/100,100)
local counter = 0
for rarity, weight in pairs(petModule.rarities) 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
is there a way to take out the selected pet ( server script) rarity from the module?