Why is this code not giving a badge?

so I’m working on a game, and i want to award the player a badge when they leave the game.
I have some code to check if i have the badge or not when i join the game again, and it says i do not.

this code isn’t giving the player a badge when they leave:

local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")

local badgeId = 1605716020924272 -- this is the correct badge ID

Players.PlayerRemoving:Connect(function(player)
    BadgeService:AwardBadge(player.UserId, badgeId)
end)


1 Like

Hi. You cannot give a badge to a player not present on the server.

2 Likes