Badge wont award?

hi
FYI this is not my code.
I decided to pitch in and help but so far nothing. The code segments:
script.BadgeAward:FireServer()
print(“FIRED SHOULD RECIEVEe”)

script.Parent.BadgeAward.OnServerEvent:Connect(function(player)
print(“Recieved.”)
game.BadgeService:AwardBadge(player.UserId, 2147267810)
end)

Does anybody know how to fix this? Thanks!

Change “OnServerEvent” to “OnClientEvent”.

Does a local script fire the event?

Well it would only be OnClientEvent if the server fires it to the client, also you can’t award a badge on the client.

client to server

Not sure what the current setup is, but my guess is that the server script is parented to the ReplicatedStorage (due to the “script.Parent.BadgeAward”) in which case scripts don’t run in that container, and instead should be in the ServerScriptService

How to:

Put a RemoteEvent in the ReplicatedStorage, name it “AwardBadge”

Paste this in a local script in the PlayerScripts / PlayerGUI / Character / Wherever it will run as you need it to:

local rs = game:GetService("ReplicatedStorage")
local award_Badge_Remote = rs:WaitForChild("AwardBadge")

award_Badge_Remote:FireServer()

Paste this in a Script that's parented to the ServerScriptService
local bs = game:GetService("BadgeService")
local rs = game:GetService("ReplicatedStorage")
local award_Badge_Remote = rs:WaitForChild("AwardBadge")

local function award_Badge(plr)
 bs:AwardBadge(plr.UserId,2147267810)
end
award_Badge_Remote.OnServerEvent:Connect(award_Badge)

Good job, you did it :+1:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.