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
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.
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.
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.
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.