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.
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.
if BadgeService:IsLegal(2124499068) and not BadgeService:IsDisabled(2124499068) then
game:GetService("BadgeService"):AwardBadge(plr.UserId, 2124499068)
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?
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?