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)
LocalScripts do not run if they are a descendant of workspace. They’re only able to run in a few containers.
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)