Badge Giver script not working

I create the badge script, but it doesn’t work for other players. Only works for me and idk why.

Here is the script:

Update 1:
Now I think it works, but I have a little bug. Some users getting the badge and some no.
Update 2:
The script works right now, but if I put it in the egg launcher is delayed and Idk why.

I used this models:

Check the developer console, if that player has that badge already, it won’t give it, but it will warn in console.

Could you send a picture of your console?

1 Like
  • Is this run Server-sidedly?
  • Is the owner of the badge the owner of the badge?
  • Did you enable the badge?
  • If it is a place, is the place part of the game associated with the badge?
  • Did you read BadgeService:AwardBadge before asking;

As well as I suggest running the following function to award a badge (this is found on the BadgeService:AwardBadge page):

local BadgeService = game:GetService("BadgeService")
 
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 awarded, errorMessage = pcall(function()
				BadgeService:AwardBadge(player.UserId, badgeId)
			end)
			if not awarded then
				warn("Error while awarding badge:", errorMessage)
			end
		end
	else
		warn("Error while fetching badge info!")
	end
end
1 Like

Here it is:

What about the server? The badge giver is not clientsided as far I see.

Also make sure that the badge is enabled and is inside your game.

Badge is active:

Check your Server Console as well, you might get the warning there instead

I’d also do a couple sanity checks, preferably:

  • Using UserHasBadgeAsync so that it doesn’t award it again to other players

  • Checking if the Hit’s Parent is an accurate Character Model

  • Print the player’s names & do make sure that the badge is in your place

1 Like

Now I think it works, but I have a little bug. Some users getting the badge and some no.

Hm, looking at your code could you try this?

local BadgeService = game:GetService("BadgeService")
local ID = 2124713368
local Part = script.Parent
local PartCooldown = false

print("Script should be online?")

Part.Touched:Connect(function(Hit)
    local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
    print("Part Touched")

    if Player and PartCooldown == false then
        PartCooldown = true
        print("Part Touched by a Player")

        if not BadgeService:UserHasBadgeAsync(Player.UserId, ID) then
            BadgeService:AwardBadge(Player.UserId, ID)
            print(Player.Name.." has been awarded this badge!")
        else
            warn(Player.Name.." already has this badge!")
        end

    wait(1)
    PartCooldown = false
    end
end)

Bit strange that it’s happening to some users

1 Like

I used the script and open my console. It’s not printing me a message about the badges

Check your Output on the Server Side and not the client

1 Like


I’m getting only this. Is about other scripts.

Alright chances are it’s probably something relevant outside the Touched function or close to inside’ish

This is the dumb check Can you make sure that the script isn’t disabled at all? Also I went ahead and edited it, might wanna try it again

1 Like

I checked and script is enabled.

Have you checked the updated script yet?

1 Like

Yes. I’m checked. spoiler[/spoiler]

I’m tested it with other players and they told me they getting badge by wait some time for example 2min.

I cannot open that spoiler text

2 minutes??? How though? It shouldn’t take that long to reward a badge? I find that extremely weird

Yes, I know, a badge should be granted immediately. Could it be the launcher’s fault for this item?

Honestly I have no clue, if your badges are delaying on rewarding to other players then it might be a bug of some sort? It might also depend on how much objects you have in your game, but I highly doubt that

Do some sanity checks to confirm the issue that’s happening, then message @Bug-Support to see if they could fix the issue

You could also create a new place, but that’d waste you another 100 robux so idk

1 Like