Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I have no idea how to give badges in game with a giver...Can you help?

Hello! First of all, im still learning so don't judge me ;-;. Secondly, I already have made a badge, and im wondering how to give it when it's touched. The reason im doing this is because the answers to these questions were 5 years ago. Im sure this is the beginnings I could use maybe(optional)**

if game.workspace.Part.Touched then

or

function onTouch()

Please help!

P.s please tell me if i use local script or just script

2 answers

For awarding the badges, look at this post on the Roblox Developer Hub

As for the in-game side of things, use this:

local Part = game.Workspace.Part 

Part.Touched:Connect(function()
	AwardBadge() -- This would be where your badge awarding function is called
end)

Don't forget to check if the player already has the badge (which is covered in the post that I have linked), and add a Debounce if you find that you need it.

Hello, here's the script you wanted:

THIS IS A SCRIPT!

  local Part = game.Workspace.Part
  local BadgeService = game:GetService("BadgeService")
    
    function awardBadge(player, badgeId)
    	
    	if BadgeService:IsLegal(badgeId) and not BadgeService:IsDisabled(badgeId) then
    		
    		BadgeService:AwardBadge(player.UserId, badgeId)

    	end
    end

	Part.Touched:Connect(function(hit)
  		if hit.Parent:FindFirstChild("Humanoid") then
			awardBadge(game.Players[hit.Parent.Name].UserId,000000) -- insted of the zero's put ur badge id in
		end
	end)
 

use it if you want to

1 comment

0

Use :GetPlayerFromCharacter() instead, since object[name] will be deprecated soon

This discussion is preserved as it was. New answers, comments, and votes are closed.