Badge not awarding?

I have added some new badges in my game (which older players may be qualified to earn) so i have this script set up:

for i,v in pairs(checkpoints:GetChildren()) do
			if tonumber(v.Name) > data then return end -- plr doesnt own
			
			local badgeid = v:FindFirstChild("BadgeId")
			
			if badgeid and badgeid.Value then
				local badgeserv = game:GetService("BadgeService")

				if not badgeserv:UserHasBadgeAsync(player.UserId, badgeid.Value) then
					
					local data, err = pcall(function()
						badgeserv:AwardBadge(player.UserId, badgeid.Value)
					end)
					
					if err then warn("badge awarding error: " .. err) end
					
					print("awarded badge to " .. player.Name .. " because they didnt have it beforehand")
				end
			end
		end

I’ve tested it, the badge numbers are correct (printed it), it prints that the badge was awarded (so its actually running), I tried it in actual roblox and it did not work. (its running on PlayerAdded)

Thanks.

1 Like

Do you by chance already own the badge? You could try deleting the badge from your inventory to see if you can earn it again. I don’t see any errors with your code.

No, I didn’t own the badge, but I just tested it out again and now it works, even though I didn’t publish anything, could it have been a roblox issue?

Please mark this post as solved.

1 Like

The issue is still occurring, only randomly does it actually award.

1 Like

try printing every check point it loops through, maybe it started looping through all the checkpoints before all of them loaded in.

i was just about to say that but you beat me to it lol great minds think alike

1 Like

BadgeService has a limit, even tho its quite high (50 + 35 * [number of users] per minute).
Try to add a task.wait(1) between each award.

Make sure the badges are configured correctly in the Roblox developer portal. The badges must be active, and your game must have permission to award them. Double-check the badge ID and permissions.

Badge IDs should be numbers (integers). Double-check that badgeid.Value is a valid number and not mistakenly a string or nil.

1 Like

I have only around 2 badges, earlier I also made it print out the badge id, and that matches, the server already has someone in it, and the script is server-sided too. The badge sometimes works, sometimes doesn’t, but always shows a result in output from the print at the end, so its not getting stopped anywhere.

Might try a bit later to put it in a different server script, just to see, could it be possible that the badge is being awarded too early for the client?