Badge Award Help

So, I have this script where it is supposed to be awarded when a player triggers a ProximityPrompt. However, it does not award and nothing prints. This is a LocalScript and I have tried to resolve my issue. It may be so simple, but I am a bad scripter. Please help any way you can!!


local BadgeService = game:GetService("BadgeService")
local proxprompt = script.Parent

local Players = game:GetService("Players")
local player = Players.LocalPlayer

proxprompt.Triggered:Connect(function()
	print("PROMPT TRIGGERED")

	if player then
		print(player.UserId)
		BadgeService:AwardBadge(player.UserId, badgeId)
	else
		print("Local player not found")
	end
end)

(Yes the script is in a proximityprompt)

2 things:

  1. LocalScripts do not run if they are a descendant of workspace. They’re only able to run in a few containers.
  2. You cannot award a badge to a player on the client. It must be on the server.

Luckily, ProximityPrompt.Triggered returns the player who triggered the prompt as the first parameter, so you can utilize that. Change your LocalScript to a Script and replace it with this:

local BadgeService = game:GetService("BadgeService")
local proxprompt = script.Parent
local Players = game:GetService("Players")

proxprompt.Triggered:Connect(function(player)
	print("PROMPT TRIGGERED")

	if player then
		print(player.UserId)
		BadgeService:AwardBadge(player.UserId, badgeId)
	else
		print("Local player not found")
	end
end)

Awardbadge dosent work in local scripts

Okay, thank you for that. However, it prints “localplayer not found”

I did not know that! Thank you for that

1 Like

Are you defining the player parameter?

proxprompt.Triggered:Connect(function(player) -- player here
1 Like

No, now i have. The script worked. Thanks a lot!

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