Awarding a badge when clicking a model

I am trying to make a model that gives a badge to the player that clicked it but I get the error "Userid is not a valid member of Player “Players.smartcarman1"”

Here’s my script:

local ClickDetector = script.Parent.ClickDetector
local badgeservice = game:GetService(“BadgeService”)
local id = 2124746316

ClickDetector.MouseClick:Connect(function(plr)
print(“Mouse Clicked!”)
badgeservice:AwardBadge(plr.Userid,id)
end)

Try using a LocalScript. Unless you were?

badgeservice:AwardBadge(plr.UserId, id)

1 Like

No, this isn’t the problem.


When an error like that appears, you likely misspelled something. In this case, you misspelled “Userid”

Since Roblox is case-sensitive, do UserId, not Userid.

Fixed code:

local ClickDetector = script.Parent.ClickDetector
local badgeservice = game:GetService("BadgeService")
local id = 2124746316

ClickDetector.MouseClick:Connect(function(plr)
   print("Mouse Clicked!")
   badgeservice:AwardBadge(plr.UserId, id)
end)
2 Likes