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

This script that gives you a badge for getting 1000 kills doesn't work?

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.
Currency = "Kills" -- Copy this script and change the new one into Whatever your game is 
BadgeID = 235167703 -- Change that to the badge's ID 
while true do 
wait() 
for i,v in pairs(game.Players:getPlayers()) do 
if v.leaderstats[Currency].Value > 1000 then --Change this to whatever your value is 
ser = game:getService("BadgeService") 
ser:AwardBadge(v.UserId,BadgeID) 
end 
end 
end 

2 answers

✓ Accepted answer

Gerenaderade is right, but that's a very bad way to do that kind of thing. Here:

local currency = 'Kills';
local badgeId = 235167703;
local needed = 1000;

game.Players.PlayerAdded:connect(function(plr)
    local statsHolder = plr:WaitForChild('leader stats');
    local stat = stats holder:WaitForChild(currency)
    stat.Changed:connect(function()
        if stat.Value == needed then
            game:GetService('BadgeService')'AwardBadge(plr.userId, badge is)
        end
    end
end)

5 comments

0

Workspace.Kills Badge Script:10: unfinished string near ''AwardBadge(plr.userId, badge is)'

0

Line 10 should be game:GetService('BadgeService'):AwardBadge(plr.userId, badgeId)

0

Also, line 6 should wait for leaderstats, not leader stats.

0

Thanks!

0

sorry, blame phone autocorrect.

UserId should be userId

Lua is CaSe-SeNsItIvE

I don't know if this might fix the whole script, but it might help.

3 comments

0

Spelling Really does Matter in Lua, so Check and Double Check +1

0

It still says leaderstats is not a valid member of Player

0

There is another problem with the code as well; What if 'Kills' or 'leaderstats' is not existant at time of execution?

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