Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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 :)

This discussion is preserved as it was. New answers, comments, and votes are closed.