Why Doesnt My Badge Awarding Code Work?

Looking at my code this should have worked. Am I missing something?

local badgeService = game:GetService("BadgeService")
local badge1 = 2125428738 -- aka ALPHA PLAYER Badge

-- badge1
game.Players.PlayerAdded:Connect(function(plr)
	-- check player badge status
	local hasBadge = badgeService:UserHasBadgeAsync(plr.UserId, badge1)
	if hasBadge then
		print(plr.Name .. "Owns This Badge Already.")
	else
		-- Award Badge if Player doesnt have it. 
		badgeService:AwardBadge(plr.Userid, badge1)
	end
end)

Just released my game update, and this bug poped up. Would appreciate any responses.

1 Like

It seems you misspelled UserId in your else block.

1 Like

Oh, my-

Thank you for spotting that. I thought I did thoroughly check my code, I guess not.

1 Like

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