Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I tried making it so if you touch a part, you would get a badge but it doesnt work, how do i fix it?

Asked by 2 years ago

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?

1 answer

Log in to vote
0
Answered by 2 years ago

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)
Ad

Answer this question