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

How do I make this script realize I want to award a badge not some model?

Asked by 4 years ago
Edited by User#5423 4 years ago
local badge = 2124515348
game.Players.PlayerAdded:Connect(function(player)
    if player.UserId == 214710102 then 
        for i, v in pairs(game.Players:GetChildren()) do
            if v:IsA("Player") and not      game:GetService("BadgeService"):UserHasBadge(v.UserId, badge) then
                game:GetService("BadgeService"):AwardBadge(v.UserId, badge)
            end
        end
    end 
end)

When I try this it returns ' BadgeId '2124515348' is not of type Badge.'

Hi in the middle of posting this I figured out the problem, My badge has the same id as some model, look: https://web.roblox.com/library/2124515348/SolidModel https://web.roblox.com/badges/2124515348/You-met-the-owner How can I fix the script to see that I am talking about the actual badge and not the model?

0
Can you change a badge id? marine5575 359 — 4y
0
You could try getting the badge id from the badge service? marine5575 359 — 4y
0
Try contacting roblox about this, or make a new badge marine5575 359 — 4y
0
edit:- fixed links User#5423 17 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Try using this??

local BadgeService = game:GetService("BadgeService")

    local function awardBadge(player, badgeId)
        -- check badge can be awarded
        if BadgeService:IsLegal(badgeId) and not BadgeService:IsDisabled(badgeId) then
            -- award badge
            BadgeService:AwardBadge(player.UserId, badgeId)
        end
    end
-- when you need to award a badge
awardBadge(player,2124515348)
0
Please explain this code in more detail User#5423 17 — 4y
0
the code checks if the badge is a badge or not iiConstable_Subwayx 130 — 4y
0
and it returns false, the badge isnt recognized as a 'legal' badge iiConstable_Subwayx 130 — 4y
Ad

Answer this question