petModule.rarities={Legendary=5;Rare=15;Uncommon=30,Common=50}petModule.chooseRandomPet=function()local h=math.random(1,100)local o=0 for W,Q in pairs(petModule.rarities)do o=o+Q if h<=o then local h=petModule.pets[W]local o=h[math.random(1,#h)]return o end end end return petModule

petModule.rarities = {
	
	["Legendary"] = 5; -- 5% chance

	["Rare"] = 15; -- 15% chance
	
	["Uncommon"] = 30; -- 30% chance
	
	["Common"] = 50; -- 50% chance

}

petModule.chooseRandomPet = function()

	local randomNumber = math.random(1,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
