So, I found a script online to award a badge when they have reached a certain amount of Cash or exceeded. I made some adjustments, but it still does not work. I think it could be a problem with the 5th line because Cash in my cash is not in leaderstats, it's just shown as a text label on screen but if I remove that line of script, I get an error about indexing nil. I refer to it as player.Cash.Value in other scripts like my developer product to award more cash or my shop to buy weapons because it's a part of the player but not a part of the player's leaderstats. I have made other changes as found in the second attempt; I added but still doesn't work. I made a local script for the third attempt and, put it in StarterPlayerScripts.
Script 1
local BadgeID = 2124831642 --My Badge ID
local Cash = "Cash" --My Money
local HowMuch = 10 --How Much They Will Need To Have
game.Players.PlayerAdded:connect(function(player)
repeat wait() until player:findFirstChild("leaderstats") ~= nil
player.Cash.Changed:connect(function()
if player.Cash.Value <= HowMuch - 1 then return end
game:GetService("BadgeService"):AwardBadge(player.userId, BadgeID)
end)
end)
Script 2
local BadgeID = 2124831642 --My Badge ID
local Cash = "Cash" --My Money
local HowMuch = 10 --How Much They Will Need To Have
game.Players.PlayerAdded:connect(function(player)
repeat wait() until player:findFirstChild("Cash") ~= nil
player.Cash.Changed:connect(function()
if player.Cash.Value <= HowMuch - 1 then return end
game:GetService("BadgeService"):AwardBadge(player.userId, BadgeID)
end)
end)
LocalScript 3
local BadgeID = 2124831642 --My Badge ID
local Cash = "Cash" --My Money
local HowMuch = 10 --How Much
game.Players.LocalPlayer.Cash.Changed:connect(function(player)
if player.Cash.Value <= HowMuch - 1 then return end
game:GetService("BadgeService"):AwardBadge(player.userId, BadgeID)
end)
