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

How to award Badge on Certain Amount of leaderstats value?

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) 

7 comments

0

There is nothing wrong with this script, are there any errors? Where are you placing the script? Is it a regular script?

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

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.

0

Yeah it doesnt seem to work on other accounts

0

@EpikLevel The script is working perfectly for me, if changing userId to UserId doesn't work then the problem is somewhere else.

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

0

Yeah it still doesnt work, my only guess is because the game is on a group

1 answer

value.Changed:Connect(function(new)
    if new >= REQUIREMENT then
        REWARDSCRIPT
    end
end)

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