@colbert2677 The following code shows the functions, weights, and for loop.
local rewards = {
[1] = {
function(plr)
if plr.EXP.Level.Value == 2 then
plr.leaderstats.Meteorite.Value += 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
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
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
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
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
game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 20 crystals and 10 moltenite! (Bronze Tier Level 10+)")
end
end,
750
},
[2] = {
function(plr)
if plr.EXP.Level.Value == 1 then
plr.leaderstats.Crystals.Value += 5
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
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
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
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
game.ReplicatedStorage.RemoteEvents.MessageGui:FireClient(plr, "You got 30 crystals, 15 moltenite, and 20 meteorite! (Silver Tier Level 10+)")
end
end,
175
},
[3] = {
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,
70
},
[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,
5
},
}
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 function egg(plr, times)
print(times)
plr.EasterEvent.Eggs.Value += times
for i = 1, times do
print(i)
local reward = rewardWeight[math.random(1,#rewardWeight)]
if rewards[reward] then
rewards[reward][1](plr)
end
print("before")
wait(0.5)
print("after")
end
end
As I said in an earlier reply, the after wait did not print. I forgot to mention that the before wait did in fact print.
If you would like the exact content of the called function, look in table rewards
.
@STORMGAMESYT7IP No I do not. I will most likely try it unless I fix it before I do.