Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

4 comments

0

Can you change a badge id?

0

You could try getting the badge id from the badge service?

0

Try contacting roblox about this, or make a new badge

0

edit:- fixed links

1 answer

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)

3 comments

0

Please explain this code in more detail

0

the code checks if the badge is a badge or not

0

and it returns false, the badge isnt recognized as a 'legal' badge

This discussion is preserved as it was. New answers, comments, and votes are closed.