Badge not given after button press

Hi everyone,

Gosh it’s been so long since I posted. Good to see y’all again B)

I am completely new to badges; I need some help on why the badge is not being awarded.

local p = game:GetService("Players").LocalPlayer
local b = script.Parent
local bs = game:GetService("BadgeService")
local id = 2126491498

b.MouseButton1Down:Connect(function()
		bs:AwardBadge(p.UserId, id)
	wait(1)
	p:Kick("ur not welcome.")
end)

This is the code that I use.

image
This is the error. I also tried obtaining the badge from the actual game but still nothing. :confused:

Any help, please?
Thanks!
Aki

Badges cannot be awarded on the client. Use aa Remoteeee Evenmt…

1 Like

Is your script a local script?

1 Like

Yes, it is. spoiler[/spoiler]

Try making a Remote-Event that gives the badge to the player

Bildschirmfoto 2022-05-23 um 12.47.54

Localscript:

script.Parent.MouseButton1Down:Connect(function()
	game:GetService("ReplicatedStorage").GiveBadge:FireServer()
end)

BadgeGiver:

local bs = game:GetService("BadgeService")
local id = 2126491498
game:GetService("ReplicatedStorage").GiveBadge.OnServerEvent:Connect(function(plr)
	bs:AwardBadge(plr.UserId, id)
end)

DISCLAIMER: Im not sure if it workes but there were no errors while coding or testing

1 Like

Erm, a little bit more information, please? :sweat_smile:

You cannot give badges from a localscript, it needs to be from a normal server script

1 Like

Client:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("badge")
local b = script.Parent

local id = 2126491498
b.MouseButton1Down:Connect(function()
    remoteEvent:FireServer(id)
end)

Server:

local bs = game:GetService("BadgeService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("badge")
function givebadge(plr, id)
    local userid = plr.UserId
    bs:AwardBadge(userid, id)
end
remoteEvent.OnServerEvent:Connect(givebadge)
1 Like

Do not forget to create Remote-Event called “badge”

1 Like

Just realised that your script had to be a local because its using “LocalPlayer”

1 Like