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.
It works! thank you for the help.
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)
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 ( ” doesn’t work unlike " )
But anyway, it’s fine. I’m new too
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)
Lmk if that works or if there is any errors in the output
It works correctly! Thank you for improving the script
Yay. I am glad it works and hey I found the code button in the process lol.
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
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
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.