Badge Error; Badge Problem

Hello! It is @Enchanted_Tix here and I found a problem on my script… Let me show you everything about my game so you can catch up. There is badges in my game and datastore2. I tested it and there was no errors. Here is the script:

game.Players.PlayerAdded:Connect(function(plr)
	if plr.PlayerStats.Wins.Value >= 10 then
		game:GetService("BadgeService"):AwardBadge(plr.UserId, 2124499068)
	elseif plr.PlayerStats.Wins.Value >= 50 then
		game:GetService("BadgeService"):AwardBadge(plr.UserId, 2124499070)
	elseif plr.PlayerStats.Wins.Value >= 100 then
		game:GetService("BadgeService"):AwardBadge(plr.UserId, 2124499200)
	end
end)

Please message me and see what is wrong with this line of script.

3 Likes

you have to tell us what you want to achieve

When the player hits 10, 50, or 100 wins, they get the badge.

Here’s a quick reference:

I don’t think you don’t understand what I am saying…

try putting this line(that link was to help you:

if BadgeService:IsLegal(badgeIdhere) and not BadgeService:IsDisabled(badgeIdhere) then

You’re using the >= operator for all checks and due to this, no matter how many wins the player has, they will always receive the first badge as they need 10 wins or higher and the other checks will never occur. Consider checking if the wins value is also lower then a certain value or invert the order in which you check them.

I will try it but what is after the ‘then’??

before the then as so:

if BadgeService:IsLegal(2124499068) and not BadgeService:IsDisabled(2124499068) then
    game:GetService("BadgeService"):AwardBadge(plr.UserId, 2124499068)

@RetributionVI but it doesn’t matter if they get the first badge and then the badge that is close to the one that they needed to earn.

How do I check how much wins they have??

You’re doing it correctly no worries, my only concern is that sometimes you should use :WaitForChild. Oop, forgot to ask you an important question. Is it a local script or a server script?

Reply to your latest reply: yes

Okay, so do I put the line of script inside the plr.PlayerStats.Wins.Value >= 10 then?
And it is a server script.

For example, if I have 80 wins, I will not receive the badge which requires 50 or more as I also have 10 or more wins and that is what is checked first. I would invert the order in which you check the badges in order to award them correctly.

game.Players.PlayerAdded:Connect(function(plr)
	if plr.PlayerStats.Wins.Value >= 100 then
		game:GetService("BadgeService"):AwardBadge(plr.UserId, 2124499200)
	elseif plr.PlayerStats.Wins.Value >= 50 then
		game:GetService("BadgeService"):AwardBadge(plr.UserId, 2124499070)
	elseif plr.PlayerStats.Wins.Value >= 10 then -- if a player has any value of wins over 10 they will only get this badge if it was the first check
		game:GetService("BadgeService"):AwardBadge(plr.UserId, 2124499068)
	end
end)

This may not be the issue you’re currently facing, but this would have been one if it was not given attention. What exactly is the issue you are having with this script?

It is a server script, indeed.

wait, I think I’ve got the problem: you already have the badge, so it doesn’t show

I did it. I will test it after…

@VegetationBush but I checked the badge and it said that noone received the badge…

Do I put the line of script inside the plr.PlayerStats.Wins.Value >= 10 then ?

Nono, you don’t get my point, if you created the badge, you automatically have it, and I think you don’t get it again, so that’s why it doesn’t show.

And yes, you do