Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I reward badges based on stats in the leaderboard?

Asked by 7 years ago

I'm new to scripting and I was wondering how I would script a badge to award players when they acquired a certain amount of cash in the game. I know it should use an If statement but I'm not sure how. I was thinking on the lines of

local badgeID = 111111
if player.leaderstats.cash = 100000 do
    badgeservice:Awardbadge(p.userid, badgeID)
endend

If someone could lead me in the right direction that would be great.

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
stat = "KOs"
needed = 5
player = game.Players.LocalPlayer
id = 00000
wait()
player.leaderstats[stat].changed:connect(function()
    if player.leaderstats[stat].Value>(needed-1) then 
        game:getService("BadgeService"):AwardBadge(id,player.PlayerId)
    end 
end)

should work :)

Ad

Answer this question