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 5 years ago
Edited by User#5423 5 years ago
01local badge = 2124515348
02game.Players.PlayerAdded:Connect(function(player)
03    if player.UserId == 214710102 then
04        for i, v in pairs(game.Players:GetChildren()) do
05            if v:IsA("Player") and not      game:GetService("BadgeService"):UserHasBadge(v.UserId, badge) then
06                game:GetService("BadgeService"):AwardBadge(v.UserId, badge)
07            end
08        end
09    end
10end)

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 — 5y
0
You could try getting the badge id from the badge service? marine5575 359 — 5y
0
Try contacting roblox about this, or make a new badge marine5575 359 — 5y
0
edit:- fixed links User#5423 17 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Try using this??

01local BadgeService = game:GetService("BadgeService")
02 
03    local function awardBadge(player, badgeId)
04        -- check badge can be awarded
05        if BadgeService:IsLegal(badgeId) and not BadgeService:IsDisabled(badgeId) then
06            -- award badge
07            BadgeService:AwardBadge(player.UserId, badgeId)
08        end
09    end
10-- when you need to award a badge
11awardBadge(player,2124515348)
0
Please explain this code in more detail User#5423 17 — 5y
0
the code checks if the badge is a badge or not iiConstable_Subwayx 130 — 5y
0
and it returns false, the badge isnt recognized as a 'legal' badge iiConstable_Subwayx 130 — 5y
Ad

Answer this question