Can't award badge through RE/RF from LocalScript in Workspace to ServerScript

Alright so, I’ve got a character avatar with a dialog in Workspace. The Dialog is grouped under the character’s Head. If you choose one of the dialog options of said dialog, I want to award a badge to the player. Now, since I’m also looking to be as exploit-proof as possible, I wanted to use Remote Functions instead of Remote Events, but it doesn’t seem to work. Neither do Remote Events, whyever.

The output is absolutely blank, nothing. No error, no warning, blank. And before I spend hours trying to figure out what’s causing it myself and wasting time trying possible solutions, I thought it’s better if I ask for help here.

The LocalScript I inserted into the dialog to notify the server about that player choosing a dialog option.

local dialog = script.Parent
local BadgeRF = game:GetService("ReplicatedStorage"):WaitForChild("ZenvionBadgeAward")

dialog.DialogChoiceSelected:Connect(function()
	
	BadgeRF:InvokeServer()
	
end)

ServerScript in ServerScriptService that’s supposed to award the badge.

local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")
local AwardRF = game:GetService("ReplicatedStorage"):WaitForChild("ZenvionBadgeAward")

local badgeId = 2144564048

AwardRF.OnServerInvoke = function(player)

	local success, badgeInfo = pcall(function()

		return BadgeService:GetBadgeInfoAsync(badgeId)

	end)

	if success then

		if badgeInfo.IsEnabled then

			local awardSuccess, result = pcall(function()

				return BadgeService:AwardBadge(player.UserId, badgeId)

			end)

			if not awardSuccess then

				warn("Error while awarding badge:", result)

			elseif not result then

				warn("Failed to award badge.")

			end

		end

	else

		warn("Error while fetching badge info: " .. badgeInfo)

	end

end

1 Like

Have you tried inserting prints to pinpoint where the issue is?

LocalScripts don’t run in Workspace, so make sure it’s parented in something like StarterGui. Once you’ve done that, change the reference of the Dialog variable to point to wherever Dialog is Parented like workspace.NPC.Dialog. This should fix your issue. :slight_smile:

It runs now, thanks. But now it’s telling me it failed to award a badge and I think I’ve just a while ago seen a post that had a similar issue. But I’m not sure if that’s really the same issue.

I did, no output either, but yeah that’s resolved now.

Nope, what I’ve seen is another error as a whole since that was something about a cooldown. Man, I wish the output gave some more detailed help…
" 21:38:24.480 Failed to award badge. - Server - BadgeHandler:26"
It’s the ServerScript, line 26 is plainly the warning message about the failed awarding.

Is the place you’re trying to award this, the same place the badge exists in?

A group owns the game if that matters.
The badge is under the “Associated Items” tab of the experience in the new developer dashboard.

ID is 2144564048, so no number error there either.

As long as the place you’re trying to award this badge in is part of the universe that the badge resides in, there’s no issue with it being a group game. Is it the same place you’re awarding in or a test place that doesn’t contain the badge?

It’s the actual game I develop, the badge is under that game and also earned in it.
We’re also not using places within Experiences, it’s a simple obby. There’s solely the main game with the obby.
All that there is, that works with places and stuff, is a Soft Shutdown Script, that I doubt that’s causing issues.

I mean… I’m not a starter developer either, but I’m certainly far off from being professional. Aside from the workspace and local script thing, I found no issue either. Wouldn’t be my first game I spend days trying to get to work.

Hmm… My apologies, aside from the help that I gave, I’m not entirely sure at this point. So long as the badge is able to awarded (which you check for) and it’s in the same place you’re trying to award in, it should work with no issues. Sorry!

Yeah, I understand. I hit my limits with global leaderboards as well, so yeah, I can relate.
Thanks for your time and your advice though!
I’ll wait and see if someone else maybe has an idea of what I can try.

Do you own the badge? And is it enabled?

I work for the Studio that owns the game, I don’t own it. Neither the group. And yes, it’s active, according to the Developer Dashboard.

Does the game own it though? (Or the does the badge owner also own it?)

Yes, the game owns the badge. Not sure about the second part, how would I check that?

Check the group owner inventory. (I presume the game belongs to the group)

The group owner doesn’t have the badge earned if that’s what you refer to.

Then that’s why. They need to upload it themselves.