Welcome Badge not working no matter what

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)

From what I can see this is a PlaceId, not a BadgeId. Please can you check that you have copied the correct id.

I just checked, it is a badgeID.

Why do you have badge id defined but then you hard code it

I haven’t scripted in awhile but it should be

local badgeid = 5691301100
local badgeservice = game:GetService("BadgeService")
game.Players.PlayerAdded:Connect(function(plr)
		badgeservice:AwardBadge(plr.UserId, badgeid)
	end)

I think

That’s what i was thinking

No thats not the problem its just weird that he hard coded it, when he has it defined before

I just tried the script, didn’t work.

Perhaps this will help setting you in the right direction

Badges | Documentation - Roblox Creator Hub

Hmm, can I got your script type? (Local or not)

Try this function that I totally didnt steal from the docs :sunglasses:

@Popben9787

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

Is the badge enabled? If it isn’t, then enable it



Make sure the id is right, bc from what i see is that either the badge isn’t enabled or it’s a wrong id

2 Likes
  1. Create NON-LOCAL script IN ServerScriptService.
  2. 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)
  1. MAKE SURE THAT YOU’RE ENABLED YOUR BADGE OR WRITED THE ID CORRECTLY.
4 Likes

Could you please tell me the type of script that it is?

Ik why it’s not working. He put invalid BadgeId. (https://www.roblox.com/badges/5691301100)

I double checked it. Yeah I thought I was putting in the Right BadgeID but it turns out I was just putting in the ID in the URL.

I found the actual ID: 301403864539422

1 Like

Can u provide your game link and badge name you want to award, or give a link on it?

1 Like

So, follow the steps above to award it.

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)

*Thanks for marking it as solution.