How to make the Proximity Prompt give a badge

  1. What do you want to achieve? Giving a badge with the proxmity prompt

  2. What is the issue? The badge script I’m using give the badge to everyone on the server and I only want it to give to the player who activates it

Script (Found in the toolbox) :

ID = 2129488332
game.Players.PlayerAdded:connect(function(plr) 
	script.Parent.Triggered:Connect(function()
		b = game:GetService("BadgeService") 
		b:AwardBadge(plr.userId,ID) 
	end)
end)
  1. What solutions have you tried so far? I tried to found a YouTube tutorial but I didn’t found

Put this script in ServerScript.

ID = 2129488332
local BadgeService = game:GetService("BadgeService") 
script.Parent.Triggered:Connect(function(plr)
	if plr then
		if not BadgeService:UserHasBadgeAsync(plrr.UserId, ID) then
				BadgeService:AwardBadge(plr.UserId, ID) 
		end
	end
end)

You made a mistake on ,

Its supposed to be a Capital UserId (U)

The game.Players.PlayerAdded function is unneeded, as the .Triggered event fires a player argument.

Try this code:

ID = 2129488332
b = game:GetService("BadgeService") 

script.Parent.Triggered:Connect(function(plr)
	b:AwardBadge(plr.UserId,ID) 
end)
1 Like

Its better to do local b = game:GetService("BadgeService") than leave it as a scope

1 Like

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