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

How should I make a script that gives you a badge using a touch event?

I've been trying to figure out how to use a touch event badge script for a while now. I've tried multiple scripts, like this one.

local badgeID =123456789  -->Whatever your badge id is
local badgeService = game:GetService("BadgeService")
function onTouch(player)
    badgeService:AwardBadge(player.userId, badgeID)
end
game.Workspace.Badge.Touched:connect(onTouch)

That did not work. Do any of you know how to do this?

1 answer

✓ Accepted answer
local badgeService = game:GetService("BadgeService")
local players = game:GetService("Players")
local badgeID = 000000000

function onTouch(hit)
	local player = players:GetPlayerFromCharacter(hit.Parent)
	if player then
	    badgeService:AwardBadge(player.UserId, badgeID)
	end
end

script.Parent.Touched:Connect(onTouch)

This script is meant to be placed within the brick you want to effect Make sure to change the badgeID value to the ID of your badge, and it should work

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