Hello, I have a script where it’s supposed to give you a badge once you reach 50 of a “kills” stat. This script worked before until I copied it over to a new experience. I made a new badge in the new experience and made sure the ID in the script was correct and I can’t tell what’s wrong with it. It’s also in serverscriptservice.
Does anybody know what’s wrong with it?
Here it is:
local players = game:GetService("Players")
local badgeService = game:GetService("BadgeService")
local badge50Kills = 2127944307
players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Value = 0
kills.Parent = leaderstats
kills.Changed:Connect(function(newVal)
if newVal >= 50 then
if badgeService:UserHasBadgeAsync(player.UserId, badge50Kills) then
print("User has badge already!")
else
badgeService:AwardBadge(player.UserId, badge50Kills)
print("Badge awarded!")
end
end
end)
end)