Hi there,
Im trying to figure out how to award a badge to a player after they earn X amount of cash via a leaderstat value, there is multiple amounts with multiple badges
local badgeInfo = {
{id = 2142678232, cashThreshold = 100000},
{id = 2142678258, cashThreshold = 500000},
{id = 2142678273, cashThreshold = 1000000},
{id = 2142678293, cashThreshold = 25000000}
}
function checkForBadge(player, badge_id, cash_threshold)
if player.leaderstats.Cash.Value >= cash_threshold then
if not game:GetService("BadgeService"):UserHasBadgeAsync(player.UserId, badge_id) then
player:FindFirstChildOfClass("BadgeService"):AwardBadge(player.UserId, badge_id)
print(player.Name .. " has earned the badge!")
end
end
end
game.Players.PlayerAdded:Connect(function(player)
for _, badgeInfo in ipairs(badgeInfo) do
player.leaderstats.Cash.Changed:Connect(function()
checkForBadge(player, badgeInfo.id, badgeInfo.cashThreshold)
end)
end
end)
* i am not a scripter, this is chat gpt.