hey,
so ive made the script so far and i tested it and the chances seem to have some problems like:
min/maxs are wrong example, for bunny it says the min is 1 (which should be for the tv)
local eggModule = {}
local random = Random.new()
eggModule.Eggs = {
["Common Egg"] = {
Cost = {"Coins",500},
Secrets = {"Giant Kitty","TV"},
Rarities = {
["Doggy"] = {["Chance"] = 3750000, ["Rarity"] = "Common",["Percent"] = "37.5"},["Kitty"] = {["Chance"] = 2750000, ["Rarity"] = "Uncommon",["Percent"] = "27.5"},
["Bunny"] = {["Chance"] = 2500000, ["Rarity"] = "Rare",["Percent"] = "25"},["Bear"] = {["Chance"] = 988794, ["Rarity"] = "Epic",["Percent"] = "9.88"},
["Deer"] = {["Chance"] = 10000, ["Rarity"] = "Legendary",["Percent"] = "0.1"},["Dragon"] = {["Chance"] = 1000, ["Rarity"] = "Legendary",["Percent"] = "0.01"},
["Golem"] = {["Chance"] = 200 , ["Rarity"] = "Legendary",["Percent"] = "0.002"},["Giant Kitty"] = {["Chance"] = 5, ["Rarity"] = "Secret",["Percent"] = "5E-05"},
["TV"] = {["Chance"] = 1, ["Rarity"] = "Secret",["Percent"] = "1E-05"}
},
Pets = {
--Not done with all pets
["Doggy"] = {game.ReplicatedStorage.Assets.Pets.}
}
}
}
function GetRarityTotalChance(eggToHatch)
local total = 0
for k, v in next, eggModule.Eggs[eggToHatch].Rarities do
total += v["Chance"]
end
return total
end
function SetRandomMinMax(eggToHatch)
local currentMin = 0
local currentMax = 0
for k, v in next, eggModule.Eggs[eggToHatch].Rarities do
currentMin = currentMax + 1
currentMax = currentMax + v["Chance"]
eggModule.Eggs[eggToHatch].Rarities[k]["Min"] = currentMin
eggModule.Eggs[eggToHatch].Rarities[k]["Max"] = currentMax
end
end
eggModule.ChoosePet = function(eggToHatch)
SetRandomMinMax(eggToHatch)
local randomChance = random:NextInteger(1,GetRarityTotalChance(eggToHatch))
for k, v in next, eggModule.Eggs[eggToHatch.Rarities] do
if randomChance >= v["Min"] and randomChance <= v["Max"] then
local rarity = v["Rarity"]
local percent = v["Percent"]
local rarityTab = eggModule.Eggs[eggToHatch].Pets[k]
local chosenPet = rarityTab[1]
return chosenPet, rarity, percent
end
end
end
return eggModule
also, how do i do x2 luck
(i know i have to multiply and divide chances but im not sure which ones should get multiplied or divided)
also wondering if you have a discord so i dont have to flood this post lol