When I try awarding a badge to a player via a remote event, I keep getting an error for the line BadgeService:AwardBadge(PS[playerName].UserId, badgeId)
The error looks like this:
ServerScriptService.remoteEvents.Award42Serverside:9: invalid argument #2 (string expected, got Instance) - Server - Award42Serverside:9
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:FindFirstChild("Award42")
local function award42(playerId)
local badgeId = 2150026267
local BadgeService = game:GetService("BadgeService")
local playerName = playerId
local PS = game:GetService("Players")
BadgeService:AwardBadge(PS[playerName].UserId, badgeId)
print("Awarded Badge")
end
remoteEvent.OnServerEvent:Connect(award42)
I’m pretty sure that Argument #2 means the variable badgeId, and I’m not sure why it’s expecting a string:
What am I doing wrong?