In the script when I run it in the output it says - leaderstats is not a valid member of Player - Script 'Workspace.Kills Badge Script', Line 6 This scripts awards you a badge when you recieve 1000 kills, but it's not working.
01 | Currency = "Kills" -- Copy this script and change the new one into Whatever your game is |
02 | BadgeID = 235167703 -- Change that to the badge's ID |
03 | while true do |
04 | wait() |
05 | for i,v in pairs (game.Players:getPlayers()) do |
06 | if v.leaderstats [ Currency ] .Value > 1000 then --Change this to whatever your value is |
07 | ser = game:getService( "BadgeService" ) |
08 | ser:AwardBadge(v.UserId,BadgeID) |
09 | end |
10 | end |
11 | end |
Gerenaderade is right, but that's a very bad way to do that kind of thing. Here:
01 | local currency = 'Kills' ; |
02 | local badgeId = 235167703 ; |
03 | local needed = 1000 ; |
04 |
05 | game.Players.PlayerAdded:connect( function (plr) |
06 | local statsHolder = plr:WaitForChild( 'leader stats' ); |
07 | local stat = stats holder:WaitForChild(currency) |
08 | stat.Changed:connect( function () |
09 | if stat.Value = = needed then |
10 | game:GetService( 'BadgeService' )'AwardBadge(plr.userId, badge is) |
11 | end |
12 | end |
13 | end ) |
UserId
should be userId
Lua is CaSe-SeNsItIvE
I don't know if this might fix the whole script, but it might help.