local PlayerService = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
PlayerService.PlayerAdded:Connect(function(Player)
local BadgeCheckSuccess, BadgeCheckError = pcall(function() --pcall takes care of any errors without 'breaking' your scripts
local PlayerHasBadge = BadgeService:UserHasBadgeAsync(Player.UserId, ReplaceThisWithYourBadgeId)
if not PlayerHasBadge then
BadgeService:AwardBadge(Player.UserId, ReplaceThisWithYourBadgeId)
end
end)
if BadgeCheckError then print(BadgeCheckError) end --This will print any errors to the output.
end)