Making a proximityPrompt give a badge once triggered

The title kind of explains it all. I’m trying to make it so triggering a proximityPrompt gives you a badge. The following is my original script:

local badgeService = game:GetService("BadgeService")
local badgeId = 2125009630

script.Parent.Triggered:Connect(function(player)
	if not badgeService:UserHasBadgeAsync(player.UserId, badgeId) then
		badgeService:AwardBadge(badgeId)
	end
end)

1 Like

You need to specify what player the badge will be awarded to (badgeService:AwardBadge(player.UserId, badgeId))

3 Likes

The badgeid argument is a template you must have picked up somewhere, Write a badge id there

Also heads up, if you are awarding a badge it has to be owned by you but to check if a user has a badge doesnt have any restrictions.

1 Like

Thank you for replying! the badgeId part is used in local badgeId = 2125009630. It might be something I misunderstood while writing that. I’ve tried changing it to the badge id, but it still doesn’t award it

1 Like

How about using remoteEvent in teh proximityPrompt?

2 Likes

Thank you for replying! It might work, but I’m not that good at using remoteEvents.

2 Likes

localScript in StarterPlayerScript

local Player = game.Players.LocalPlayer
local ProximityPrompt = game.Workspace.Part.ProximityPrompt
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

ProximityPrompt.Triggered:Connect(function()
	RemoteEvent:FireServer()
	print("Work")
end)

Script in ServerScriptService

local BadgeService = game:GetService("BadgeService")
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

local Badge = (2125009630)

RemoteEvent.OnServerEvent:Connect(function(Player)
	if not BadgeService:UserHasBadgeAsync(Player.UserId, Badge) then
		BadgeService:AwardBadge(Player.UserId, Badge)
		print("Working!")
	end
end)
9 Likes

Thank you for solving it! It now works as intended.

4 Likes