Hi guys! Any ideas why this doesn't award the badge? There are no errors. Any help would be appreciated ;) Thanks!
01 | local LeaderboardString = "Coins" |
02 | local RequiredValue = 1000 |
03 | local BadgeID = 217045131 |
04 |
05 | game.Players.PlayerAdded:connect( function (Player) |
06 | local LeaderboardInstance = Player:WaitForChild(LeaderboardString) |
07 | wait( 1 ) |
08 | if LeaderboardInstance.Value > = RequiredValue then |
09 | game:GetService( "BadgeService" ):AwardBadge(Player.userId, BadgeID) |
10 | end |
11 | end ) |
I'm not sure of how you're organizing your game, but I believe you can't look for "Coins" as a direct child of Player, if you're using a leaderstat.
Thus, this should work:
01 | local LeaderboardString = "Coins" |
02 | local RequiredValue = 1000 |
03 | local BadgeID = 217045131 |
04 |
05 | game.Players.PlayerAdded:connect( function (Player) |
06 | local LeaderboardInstance = Player:WaitForChild( 'leaderstats' ):WaitForChild(LeaderboardString) -- Wait for leaderstats first, then for the LeaderboardString |
07 | LeaderboardInstance.Changed:connect( function () |
08 | wait( 1 ) |
09 | if LeaderboardInstance.Value > = RequiredValue then |
10 | game:GetService( "BadgeService" ):AwardBadge(Player.userId, BadgeID) |
11 | end |
12 | end ) |
13 | end ) |
Hope it helps! :) Comment if it doesn't work, and you're using a different scheme.
[EDIT: Added Changed
event]