✓ Accepted answer
The reason why you can't award the badge is that there's no method called FindPlayerFromCharacter in the Players service, you would have to use GetPlayerFromCharacter(). Also, your debounce logic is flipped but it doesn't really matter since it still serves the same purpose. Regardless, a better way to check if player already has a badge is using the UserHasBadgeAsync method.
Also, camelCase (variableName) connect is deprecated in favour of PascalCase Connect (VariableName). userId is also deprecated in favour of UserId.
local badgeId = 2124494023
local BadgeService = game:GetService("BadgeService")
script.Parent.Touched:Connect(function(hit)
local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if plr and not BadgeService:UserHasBadgeAsync(plr.UserId, badgeId) then
BadgeService:AwardBadge(plr.UserId, badgeId)
end
end)
If you have any questions please ask them in the comments, and if this answered your question, please mark it as the correct answer.
1 comment
Can't thank you enough, that worked!