How to make a Badge get earned when tool added

How to make a badge get earned when you get a tool added to your backpack.
I can’t find anything online
(Sorry I know this isn’t the right category, but I currently do not know where the correct one would be.)

local BadgeService = game:GetService("BadgeService")
local BadgeID = BADGE_ID_HERE

game.Players.PlayerAdded:Connect(function(Player)
   while task.wait(10) do
      if Player.Backpack:FindFirstChild("TOOLNAME") or Player.Character:FindFirstChild("TOOLNAME") then
         BadgeService:AwardBadge(Player.UserId, BadgeID)
      end
   end
end)

This might not be the most efficient way of doing it, however, this would work.

1 Like

It works! thank you for the help.

1 Like

I would do this instead. Personally I try to avoid loops if possible, just more scripts and lag running then actually needed.


local BadgeService = game:GetService("BadgeService")
local BadgeID = BADGE_ID_HERE

game.Players.PlayerAdded:Connect(function(Player)
   Player.Backpack.ChildAdded:Connect(function(ToolAdded)

if ToolAdded.Name = “Tool Name” then
         BadgeService:AwardBadge(Player.UserId, BadgeID)
      end
   end)
end)

1 Like

Bro, you forgot to set it as the code format:

local BadgeService = game:GetService(“BadgeService”)
local BadgeID = BADGE_ID_HERE

game.Players.PlayerAdded:Connect(function(Player)
Player.Backpack.ChildAdded:Connect(function(ToolAdded)

if ToolAdded.Name = “Tool Name” then
BadgeService:AwardBadge(Player.UserId, BadgeID)
end
end)
end)

I’m currently on phone, and newer to the dev forum. I am Aware, and sorry for not setting it in the format.

Also I noticed that the " that you used don’t work on studio :frowning: ( ” doesn’t work unlike " )
But anyway, it’s fine. I’m new too :smiley:

local BadgeService = game:GetService("BadgeService")
local BadgeID = BADGE_ID_HERE

game.Players.PlayerAdded:Connect(function(Player)
	Player.Backpack.ChildAdded:Connect(function(ToolAdded)

		if ToolAdded.Name = "Tool Name" then
			BadgeService:AwardBadge(Player.UserId, BadgeID)
		end
	end)
end)
1 Like

Lmk if that works or if there is any errors in the output :slight_smile:

It works correctly! Thank you for improving the script :happy1: :happy2: :happy3: :happy4:

1 Like

Yay. I am glad it works and hey I found the code button in the process lol.

1 Like

I am going to create a system in my game where people who helped me are listed as “verified” and get a tool, you could be first on the list

1 Like

Noice! I am curious to see what game your making. when your finished, feel free to message me on the dev forum and I will be more then happy to check it out!

It is actually currently published.

Game link

(Boombox Hangout - Roblox)

1 Like

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