Error granting badges to the player in a game made by my party

Hello this is my first time using devforum to report a bug, I’m having a problem getting a bedge created in my Roblox group (I’m the owner and I paid for it) to work in the script, it’s functional and has been tested in experience outside of group, in this case I want the player to receive the emblem when entering the game, something simple to do but even though the script is correct the badge does not appear in the game and in the player’s inventory, I have tried to correct it in several ways but I was unable to resolve it. Opening support I didn’t get an effective response.

Here is the game group where I created the emblem and experience :


Here is the image of the badge:

And this is the script the user receives when they touch a part: ```local BadgeService = game:GetService(“BadgeService”)
local Players = game:GetService(“Players”)

local badgeId = 3639477158844045 – Substitua pelo ID do emblema que você deseja conceder

local function onTouched(other)
local character = other.Parent
local player = Players:GetPlayerFromCharacter(character)

if player then
	local success, errorMessage = pcall(function()
		BadgeService:AwardBadge(player.UserId, badgeId)
	end)

	if success then
		print("Emblema concedido com sucesso para " .. player.Name .. "!")
	else
		print("Emblema não foi concedido para " .. player.Name .. ": " .. errorMessage)
	end
end

end```

Hello! Before I get into anything, it is a good idea to run an if statement to check if other is actually the child of a character.

if other.Parent:FindFirstChild("Humanoid") then
-- run script
end

Also, since this is a function, at what point in your script do you actually call it?

is this a LocalScript or a regular script? badges can’t be given out unless it’s called on the server, so make sure it’s a regular script

additionally, make sure your onTouched function is actually being called

Hello, I soon intend to post more details about the error I found, but in short, I am unable to make the user receive the emblem when entering the game or stepping on any part of it From the game, the game is being created in this group above, but I tested the same script in a game on my personal account (not in the group) and it worked, the error is in the group emblem itself, that’s what I have Sure, but I don’t know what to do to make the bedge created in the group game work.

When are you calling the function?

function is triggered when the object this script is attached to is touched by another object. If this object is a player (i.e. player is not null), the BadgeService service will attempt to grant the em

What type of script is the script that awards the badge? Make sure it is not a localscript as stated by @CrimsonForce and on this document BadgeService | Documentation - Roblox Creator Hub.

Also is the game giving the badge owned by the group?

What is printed into output when the badge is awarded? Does your print message for the success or failure run? Also, are you doing this from a Script or LocalScript?

Also, you should make sure that the function is actually being called correctly when the part is touched. Such as:

part.Touched:Connect(function(other)
-- your code here
end)

Or by adding this line after the function.

part.Touched:Connect(onTouched)

It is printed that “player successfully received emblem” but the badge does not appear on the player’s screen or in the inventory. I tested with the emblem two different ways of granting the emblem: when entering the game and just touch a specific part (both work in my games outside the group, but in the group game it doesn’t work)

Maybe convert the badgeID variable to a string.

Try publishing the game and then joining it normally. Maaayyybe this issue is occurring because you’re trying to do it from within studio?

I don’t think it’s that, but it’s worth a try tomorrow I’ll do it and I’ll bring more news and detail the error in more detail, I heard that it may be related to some configuration of my group itself but No solution, but tomorrow I’ll come with more images and news.

How do I convert? Can you tell me if there will be any difference in making the badge work in a game on your own account versus in a game in a group with more collaborators?

He was asking if you could use tostring() to convert the badge id into a string and try that. But no, it wouldn’t work, as AwardBadge() requires the badge id to be a number.

And as for your second question, it depends. Collaborators are easier to manage with a group, but you can still do that if the game is owned by your account. It honestly depends on the size of the project and your preference.