Simple badges for leader stats values isn't working... why?

You can write your topic however you want, but you need to answer these questions:

I am trying to check the players wins leaderstats value inside of the player on joined to check if they can receive a badge for their amount of wins…

Nothing is running when the player joins and I have no idea why…

I’ve tried looking at scripts that do the exact same thing as me that work, but mine seems not to be working.

Here is the code:

local badgeService = game:GetService("BadgeService")

local BF_1 = 2130365142
local BF_Amateur10 = 2130365227
local BF_Experienced25 = 2130365372
local BF_Pro50 = 2130365394
local BF_Skilled100 = 2130365443
local BF_Elite250 = 2130443236
local BF_Master500 = 2130443239
local BF_Grandmaster1000 = 2130443246
local BF_Legendary5000 = 2130443260
local BF_Mythical10000 = 2130443264

game.Players.PlayerAdded:Connect(function(plr)
	local function awardBadges()
		if plr.leaderstats.Wins.Value >= 1 then
			badgeService:AwardBadge(plr.UserId,BF_1)
		end
		if plr.leaderstats.Wins.Value >= 10 then
			badgeService:AwardBadge(plr.UserId,BF_Amateur10)
		end
		if plr.leaderstats.Wins.Value >= 25 then
			badgeService:AwardBadge(plr.UserId,BF_Experienced25)
		end
		if plr.leaderstats.Wins.Value >= 50 then
			badgeService:AwardBadge(plr.UserId,BF_Pro50)
		end
		if plr.leaderstats.Wins.Value >= 100 then
			badgeService:AwardBadge(plr.UserId,BF_Skilled100)
		end
		if plr.leaderstats.Wins.Value >= 250 then
			badgeService:AwardBadge(plr.UserId,BF_Elite250)
		end
		if plr.leaderstats.Wins.Value >= 500 then
			badgeService:AwardBadge(plr.UserId,BF_Master500)
		end
		if plr.leaderstats.Wins.Value >= 1000 then
			badgeService:AwardBadge(plr.UserId,BF_Grandmaster1000)
		end
		if plr.leaderstats.Wins.Value >= 5000 then
			badgeService:AwardBadge(plr.UserId,BF_Legendary5000)
		end
		if plr.leaderstats.Wins.Value >= 10000 then
			badgeService:AwardBadge(plr.UserId,BF_Mythical10000)
		end
	end
	wait(3)
	game.Loaded:Wait()
	plr:WaitForChild("leaderstats"):WaitForChild("Wins")
	awardBadges()
end)

Anything helps! Thanks, GL_CAL

When the player joins, their data might not load instantly so this script will run first and will see that the player’s wins is 0. Try adding a delay to this script.

Edit: I’ve never encountered this problem before so this may or may not work.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.