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

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

Asked by 10 years ago

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.

01Currency = "Kills" -- Copy this script and change the new one into Whatever your game is
02BadgeID = 235167703 -- Change that to the badge's ID
03while true do
04wait()
05for i,v in pairs(game.Players:getPlayers()) do
06if v.leaderstats[Currency].Value > 1000 then --Change this to whatever your value is
07ser = game:getService("BadgeService")
08ser:AwardBadge(v.UserId,BadgeID)
09end
10end
11end

2 answers

Log in to vote
3
Answered by
DrJonJ 110
10 years ago

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

01local currency = 'Kills';
02local badgeId = 235167703;
03local needed = 1000;
04 
05game.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
13end)
0
Workspace.Kills Badge Script:10: unfinished string near ''AwardBadge(plr.userId, badge is)' alan3401 28 — 10y
0
Line 10 should be game:GetService('BadgeService'):AwardBadge(plr.userId, badgeId) Merely 2122 — 10y
0
Also, line 6 should wait for leaderstats, not leader stats. Merely 2122 — 10y
0
Thanks! alan3401 28 — 10y
0
sorry, blame phone autocorrect. DrJonJ 110 — 10y
Ad
Log in to vote
3
Answered by 10 years ago

UserId should be userId

Lua is CaSe-SeNsItIvE

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

0
Spelling Really does Matter in Lua, so Check and Double Check +1 woodengop 1134 — 10y
0
It still says leaderstats is not a valid member of Player alan3401 28 — 10y
0
There is another problem with the code as well; What if 'Kills' or 'leaderstats' is not existant at time of execution? TheeDeathCaster 2368 — 10y

Answer this question