This is my code:
local badgeId = 38380038 script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") local BadgeService = game:GetService("BadgeService") local function awardBadge(player, badgeId) if BadgeService:IsLegal(badgeId) and not BadgeService:IsDisabled(badgeId) then BadgeService:AwardBadge(player.UserId, badgeId) end end end
What did i do wrong?
This might be confusing problem I ever seen. You added IsLegal (Which is Deprecated), so it won't work that way. Instead, use this:
local id = 0 -- Put your badge here. local function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) local BadgeService = game:GetService("BadgeService") BadgeService:AwardBadge(player.UserId, id) end script.Parent.Touched:Connect(onTouched)