Client Side Badge Click not working

Hello! The reason I am using a LocalScript in StarterPlayerScripts is because there is a variable I require to be client side that I want to use to enable the player to get the badge. However, the script doesn’t work as it is right now.

local door = game.Workspace:WaitForChild("Door")
local handle = door:WaitForChild("Handle")
local badgeid = 3001013084614617 -- change this as your badge id
local player = game.Players.LocalPlayer
 
local key2 = game.Workspace:WaitForChild("Key1")
 

handle.ClickDetector.MouseClick:Connect(function()
 	if keydoor2 == true then
		badgeservice:AwardBadge(player.UserId, badgeid)
		wait(1)
 		player:Kick("DEAD END")
	else
 		handle["Sound"]:Play()
 		handle.ClickDetector.MaxActivationDistance = 0
 		wait(1.525)
 		handle.ClickDetector.MaxActivationDistance = 10
 	end
end)

Thank you in advance

In BadgeService | Documentation, it says,
“The badge must be awarded from a server-side Script or a ModuleScript eventually required by a Script, not from a LocalScript.”

So just use a Remote Event.

Alright thank you I was starting to think this may be the issue. I have tried to learn remote events before but couldn’t wrap my head around them; will try again

Remote events fired from the client are not secure in this case.
Hackers can easily fire that remote event and get that badge without doing anything.

Most of this can be done on the server side, perhaps try doing it on the server and firing a remote event to the client for special client effects?

I recommend Checking out this Custom Badge Notification Article to customize getting badges, if you are interested in that.

1 Like