Hello, I am trying to award a badge to players who own a different badge (so if a player owns a badge in any other game you can award a badge in my game) However, when i join the game i dont get awarded the badge and there is no errors.
Here is my code
local BServ = game:GetService("BadgeService") local BadgeOwned = 2124582050 local BadgeAward = 2124561788 game.Players.PlayerAdded(function(plr) if BServ:UserHasBadgeAsync(plr.UserId, BadgeOwned) then BServ:AwardBadge(plr.UserId, BadgeAward) end end)
local BadgeService = game:GetService("BadgeService") local Players = game:GetService("Players") local badgeOwned = 00000000 local badgeAward = 00000000 local function onPlayerAdded(player) -- Check if player has owned badge local success, hasBadge = pcall(function() return BadgeService:UserHasBadgeAsync(player.UserId, badgeOwned ) end) -- if it trows an error, exit the function if not success then return end if hasBadge then -- Award badge local awarded, errorMessage = pcall(function() BadgeService:AwardBadge(player.UserId, badgeAward) end) if not awarded then warn("Error while awarding badge:", errorMessage) end end end -- Connect event PlayerAdded with OnPlayerAdded function Players.PlayerAdded:Connect(onPlayerAdded)
Hope it helps!