I’m trying to make a welcome badge for a game but the badge doesn’t seem to work no matter what. I’ve tried free models and a friend lend a badge script but nothing seems to give the badge. I don’t know what’s wrong.
Here’s the script:
local badgeid = 5691301100
local badgeservice = game:GetService("BadgeService")
game.Players.PlayerAdded:Connect(function(plr)
badgeservice:AwardBadge(plr.UserId, 5691301100)
end)
local function awardBadge(player, badgeId)
-- Fetch badge information
local success, badgeInfo = pcall(function()
return BadgeService:GetBadgeInfoAsync(badgeId)
end)
if success then
-- Confirm that badge can be awarded
if badgeInfo.IsEnabled then
-- Award badge
local awardSuccess, result = pcall(function()
return BadgeService:AwardBadge(player.UserId, badgeId)
end)
if not awardSuccess then
-- the AwardBadge function threw an error
warn("Error while awarding badge:", result)
elseif not result then
-- the AwardBadge function did not award a badge
warn("Failed to award badge.")
end
end
else
warn("Error while fetching badge info: " .. badgeInfo)
end
end
Put this code into it, but change BadgeId to your one:
local BadgeID = 0 -- Change to your one
game.Players.PlayerAdded:Connect(function(Player)
if not game:GetService("BadgeService"):UserHasBadgeAsync(Player.UserId, BadgeID) then
game:GetService("BadgeService"):AwardBadge(Player.UserId, BadgeID)
end
end)
MAKE SURE THAT YOU’RE ENABLED YOUR BADGE OR WRITED THE ID CORRECTLY.
local BadgeID = 301403864539422
game.Players.PlayerAdded:Connect(function(Player)
if not game:GetService("BadgeService"):UserHasBadgeAsync(Player.UserId, BadgeID) then
game:GetService("BadgeService"):AwardBadge(Player.UserId, BadgeID)
end
end)