The script is supposed to award the badge when a stat becomes a certain value. However, it is not working, and I have no idea why. Can someone please help me?
Script:
local BadgeID = 238037695 local Cash = "Friends" game.Players.PlayerAdded:connect(function(p) repeat wait() until p:findFirstChild("Friends") ~= nil p[Cash].Changed:connect(function() if p[Cash].Value == 1 then return end game:GetService("BadgeService"):AwardBadge(p.userId, BadgeID) end) end)
There is a method called WaitForChild
. Use that instead of a repeat loop.
Here:
local badgeId = 238037695; local statName = "Friends"; local neededVal = 1; local serv = game:GetService("BadgeService"); game.Players.PlayerAdded:connect(function(plr) local stat = plr:WaitForChild(statName); stat.Changed:connect(function() if stat.Value == neededVal then serv:AwardBadge(plr.userId, badgeId) end end) end)
Let me know if that works. Also if you're trying to award to yourself, that won't work. Use an alternate account.
Edited on 4/21/15: fixed errors caused by mobile