I need help with badge giving

Hello, i want to make a tool, that on use, gives you a badge. I have a working tool aready. I inserted the folowing code into it:

--before activation function
local id = -- id here
--inside activation funtion
 local b = game:GetService("BadgeService")    
 b:AwardBadge(game.Players.LocalPlayer.userId, id)

I have tried doing it in a gui before with this exact concept, it of course didnt work but i didnt know that at the time. But it sent back that it needs to run on server.

I basically have a shop GUI and i want to give an awad to players if they have buyed a certan item. I tought it would be easyer if i do it trough a tool becouse i dont really know how to use remotes events, witch is needed if im trying to acomplish it in the GUI.

Badges can’t be awarded from localscripts

2 Likes

ohhhhhhhhhhh ok thanks i will try to improve it. How do i get the player who activated the tool then?

Nvm i got it!
For anyone looking in the future its:

--this in the onActivated function
	local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
	game:GetService("BadgeService"):AwardBadge(player.UserId, BADGE_ID) 
--replace the BADGE_ID with the badge ID

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