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

How to award Badge on Certain Amount of leaderstats value?

Asked by 5 years ago
Edited by DanzLua 5 years ago

Hi, i was wondering if someone could help me with a Script that awards a badge when the player has achieved the required amount of cash. All scripts i can find seem to be outdated and do not work. This is the script i use which doesnt work

local BadgeID = 2124473380 --Badge ID Here
local Cash = "Cash"  --Change Money To The Stat
local HowMuch = 100000000 --Change To How Much They Need To Have
game.Players.PlayerAdded:connect(function(p) 
    repeat wait() until p:findFirstChild("leaderstats") ~= nil 
    p.leaderstats[Cash].Changed:connect(function() 
        if p.leaderstats[Cash].Value <= HowMuch - 1 then return end 
        game:GetService("BadgeService"):AwardBadge(p.userId, BadgeID) 
    end) 
end) 
0
There is nothing wrong with this script, are there any errors? Where are you placing the script? Is it a regular script? DanzLua 2879 — 5y
0
Is is a regular script placed in workspace and it doesnt seem to show that there are any errors, it just doesn't give me badge EpikLevel 0 — 5y
0
@EpikLevel Have you tried on another account, if you already own the badge obviously you won't see it awarded to your self. Try adding a print() because it awards the player to see if it runs, if so you have nothing to worry about. DanzLua 2879 — 5y
0
Yeah it doesnt seem to work on other accounts EpikLevel 0 — 5y
View all comments (3 more)
0
@EpikLevel The script is working perfectly for me, if changing userId to UserId doesn't work then the problem is somewhere else. DanzLua 2879 — 5y
0
Why [Cash]? Just use .Cash, it's literally the same name, why have a variable that contains the name, only to use it in place of syntactic sugar a.b that's like so pointless User#24403 69 — 5y
0
Yeah it still doesnt work, my only guess is because the game is on a group EpikLevel 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
value.Changed:Connect(function(new)
    if new >= REQUIREMENT then
        REWARDSCRIPT
    end
end)
Ad

Answer this question