- What do you want to achieve?
I want to see (pet…name) in the output and to take 800 Coins from the leaderboard.
-
What is the issue?
script:
local petModule = {}
petModule.pets = {
["Mythic"] = {
};
["Legendary"] = {
};
["Epic"] = {
};
["UnCommon"] = {
game.ReplicatedStorage.Pets.BlackCaterpillar;
game.ReplicatedStorage.Pets.WhiteCaterpillar;
};
["Common"] = {
game.ReplicatedStorage.Pets.GreenCaterpillar;
game.ReplicatedStorage.Pets.DarkGreenCaterpillar;
game.ReplicatedStorage.Pets.LightGreenCaterpillar;
};
}
petModule.rarities = {
["Mythic"] = 1;
["Legendary"] = 3;
["Epic"] = 17;
["UnCommon"] = 24;
["Common"] = 55;
}
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.pet[rarity]
local chosePet = rarityTable[math.random(1,#rarityTable)]
return chosePet
end
end
end
return module
-
What solutions have you tried so far?
I tried to change it into the Replicated Stoarge.