I decided to reroute my approach to this as you recommended.
local rewards = {
[1] = {
function(plr)
if plr.EXP.Level.Value == 2 then
plr.leaderstats.Meteorite.Value += 2
return {{Cry = 0, Met = 2, Mol = 0}, "Bronze Tier Level 2"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 2 meteorite! (Bronze Tier Level 2)")
elseif plr.EXP.Level.Value == 1 then
plr.leaderstats.Crystals.Value += 2
return {{Cry = 2, Met = 0, Mol = 0}, "Bronze Tier Level 1"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 2 crystals! (Bronze Tier Level 1)")
elseif plr.EXP.Level.Value == 3 then
plr.leaderstats.Crystals.Value += 2
plr.leaderstats.Meteorite.Value += 3
return {{Cry = 2, Met = 3, Mol = 0}, "Bronze Tier Level 3"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 2 crystals and 3 meteorite! (Bronze Tier Level 3)")
elseif plr.EXP.Level.Value >= 4 and plr.EXP.Level.Value < 7 then
plr.leaderstats.Crystals.Value += 5
return {{Cry = 5, Met = 0, Mol = 0}, "Bronze Tier Level 4-6"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 5 crystals! (Bronze Tier Level 4-6)")
elseif plr.EXP.Level.Value >= 7 and plr.EXP.Level.Value < 10 then
plr.leaderstats.Moltenite.Value += 4
plr.leaderstats.Crystals.Value += 7
return {{Cry = 7, Met = 0, Mol = 4}, "Bronze Tier Level 7-9"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 7 crystals and 4 moltenite! (Bronze Tier Level 7-9)")
elseif plr.EXP.Level.Value >= 10 then
plr.leaderstats.Moltenite.Value += 10
plr.leaderstats.Crystals.Value += 20
return {{Cry = 20, Met = 0, Mol = 10}, "Bronze Tier Level 10+"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 20 crystals and 10 moltenite! (Bronze Tier Level 10+)")
end
end,
150
},
[2] = {
function(plr)
if plr.EXP.Level.Value == 1 then
plr.leaderstats.Crystals.Value += 5
return {{Cry = 5, Met = 0, Mol = 0}, "Silver Tier Level 1"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 5 crystals! (Silver Tier Level 1)")
elseif plr.EXP.Level.Value == 2 then
plr.leaderstats.Meteorite.Value += 5
return {{Cry = 0, Met = 5, Mol = 0}, "Silver Tier Level 2"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 5 meteorite! (Silver Tier Level 2)")
elseif plr.EXP.Level.Value >= 3 and plr.EXP.Level.Value < 7 then
plr.leaderstats.Moltenite.Value += 5
plr.leaderstats.Crystals.Value += 8
return {{Cry = 8, Met = 0, Mol = 5}, "Silver Tier Level 3-6"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 8 crystals and 5 moltenite! (Silver Tier Level 3-6)")
elseif plr.EXP.Level.Value >= 7 and plr.EXP.Level.Value < 10 then
plr.leaderstats.Moltenite.Value += 8
plr.leaderstats.Crystals.Value += 15
return {{Cry = 15, Met = 0, Mol = 8}, "Silver Tier Level 7-9"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 15 crystals and 8 moltenite! (Silver Tier Level 7-9)")
elseif plr.EXP.Level.Value >= 10 then
plr.leaderstats.Moltenite.Value += 15
plr.leaderstats.Crystals.Value += 30
plr.leaderstats.Meteorite.Value += 20
return {{Cry = 30, Met = 20, Mol = 15}, "Silver Tier Level 10+"}
--game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 30 crystals, 15 moltenite, and 20 meteorite! (Silver Tier Level 10+)")
end
end,
35
},
[3] = {--not done with this yet
function(plr)
if plr.EXP.Level.Value >= 1 and plr.EXP.Level.Value < 5 then
plr.leaderstats.Moltenite.Value += 2
game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 2 moltenite! (Gold Tier Level 1-4)")
elseif plr.EXP.Level.Value >= 5 and plr.EXP.Level.Value < 8 then
plr.leaderstats.Moltenite.Value += 5
plr.leaderstats.Crystals.Value += 15
game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 15 crystals and 5 moltenite! (Gold Tier Level 5-7)")
elseif plr.EXP.Level.Value >= 8 and plr.EXP.Level.Value < 10 then
plr.leaderstats.Moltenite.Value += 20
game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 20 moltenite! (Gold Tier Level 8-9)")
elseif plr.EXP.Level.Value >= 10 then
plr.leaderstats.Moltenite.Value += 50
plr.leaderstats.Crystals.Value += 80
game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 80 crystals and 50 moltenite! (Gold Tier Level 10+)")
end
end,
14
},
[4] = {
function(plr)
if plr.EXP.Level.Value >= 1 and plr.EXP.Level.Value < 5 then
plr.leaderstats.Moltenite.Value += 15
game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 15 moltenite! (Diamond Tier Level 1-4)")
game.ReplicatedStorage.RemoteEvents.Sound:FireClient(plr, "Legendary")
elseif plr.EXP.Level.Value >= 5 and plr.EXP.Level.Value < 10 then
plr.leaderstats.Moltenite.Value += 50
plr.leaderstats.Crystals.Value += 100
game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 100 crystals and 50 moltenite! (Diamond Tier Level 5-9)")
game.ReplicatedStorage.RemoteEvents.Sound:FireClient(plr, "Legendary")
elseif plr.EXP.Level.Value >= 10 then
plr.leaderstats.Moltenite.Value += 200
game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 200 moltenite! (Diamond Tier Level 10+)")
game.ReplicatedStorage.RemoteEvents.Sound:FireClient(plr, "Legendary")
end
end,
1
},
}
local amountweights = {[1] = {70}, [2] = {22}, [3] = {8}}
local rewardWeight = {}
local amountWeight = {}
local function weightInsert(tab, inserted, partOfTab)
for i, v in pairs(tab) do
for p = 1, v[partOfTab] do
table.insert(inserted, #inserted+1, i)
end
end
end
weightInsert(rewards, rewardWeight, 2)
weightInsert(amountweights, amountWeight, 1)
local folder = script.Parent.Parent
local deb = false
local timesToOther = {
[1] = "Single",
[2] = "Double",
[3] = "Triple"
}
local function egg(plr, times)
print(times)
plr.EasterEvent.Eggs.Value += times
local things = {Cry = 0, Met = 0, Mol = 0}
local tier = "null Tier Level null"
local text = "You got 0 crystals, 0 meteorite, and 0 moltenite! (null Tier Level null, Single Egg)"
for i = 1, times do
print(i)
local reward = rewardWeight[math.random(1,#rewardWeight)]
local tab = nil
if rewards[reward] then
tab = rewards[reward][1](plr)
end
things.Cry += tab[1].Cry
things.Met += tab[1].Met
things.Mol += tab[1].Mol
tier = tab[2]
end
text = "You got "..things.Cry.." crystals, "..things.Met.." meteorite, and "..things.Mol.." moltenite! ("..tier..", "..timesToOther[times].." Egg)"
game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, text)
end
It seems to work well but I could shorten the text by removing the 0’s. Also, you could get a Bronze Tier as well as a Silver Tier, but it shows the last one. I could live with that, but I would still like an alternate for getting the tier(s).