If I were to change my networth to 6000, it skips all besides silver money bag?
local ranks = -- Array of ranks, in ascending order
{
{
NetWorth = 0,
Bag = "Starter Money Bag",
},
{
NetWorth = 525,
Bag = "Rookie Money Bag",
},
{
NetWorth = 2500,
Bag = "Silver Money Bag",
}
}
local currentRank
local stats = p:WaitForChild("Stats")
local leader = p:WaitForChild("leaderstats")
local cash = stats.Cash
networth = stats.NetWorth.Value
local function updateRank(currentNetWorth)
local rank
for _, r in ipairs(ranks) do
if r.NetWorth > currentNetWorth then
break
end
rank = r
end
if rank ~= currentRank then
local _, lastBag = pcall(function() return ranks[i-1].Bag end)
local bag = rank.Bag
givebag(p, bag, lastBag or "none")
currentRank = rank
end
end
stats.NetWorth.Changed:connect(updateRank)
updateRank(stats.NetWorth.Value) -- Update right away
######Edited ~ tab your code properly
