Achivied/Not Achivied Bagde Text

Hello, as the title of this topic says, I would like to try how to make a text that says if the player has a bagde or not. I’ve been looking for this for a long time , but taking into account that several topics like this never end up with a solution. I would like this to have at least one

EX:
The player does not have the bagde
not achivied

The player have the bagde
image

Screenshots are from this game: be a dad and get milk simulator [NEW BADGES] - Roblox

UserHasBadgeAsync method from BadgeService

local success, hasBadge = pcall(function()
	return BadgeService:UserHasBadgeAsync(player, id)
end)
if not success then 
	return
end
if hasBadge then
	-- whatever
end

note that UserHasBadgeAsync takes two Ids as argument: player and badge

And how would a textlabel show if the player has the bagde or not?

So basically if you don’t have the bagde the text puts you ‘‘bagde not achieved’’ and when you get it ‘‘bagde achieved’’

local text = script.Parent
local success, hasBadge = pcall(function()
	return BadgeService:UserHasBadgeAsync(player, id)
end)
if not success then 
	print("error")
end
if hasBadge then
	text.Text = "achieved"
else
    text.Text = "not achieved"
end

And would I have to put this inside the textlabel as a localscript?

Yes.

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

Hello, well, I tried what you put, but it gives me some errors and I don’t know what to do here…
image
Say unknow global

And it could also be done so that it is known what bagde you have or not, since it comes out that that is achivied without even having achieved it
image
image
With the last image I want to refer to the fact that I do not have the bagde

Add this,

local BadgeService = game:GetService("BadgeService")
local player = game.Players.LocalPlayer
local id = -- put your id here

Well, it no longer gives me those errors, but it keeps showing me that I have the bagde achivied and I don’t have it…

May I see your code to see why it keeps doing that?

1 Like

You automatically own the badge that you create, so dont worry your script is working totally fine

His badge is probably deleted, by looking at his image he doesn’t own his badge.

But if I delete it from my inventory, it should show "bagde not achieved’’, right? but it keeps saying i got it

This is the code
local BadgeService = game:GetService(“BadgeService”)

local player = game.Players.LocalPlayer

local id = 2125782409

local text = script.Parent

local success, hasBadge = pcall(function()

return BadgeService:UserHasBadgeAsync(player, id)

end)

if not success then

print(“error”)

end

if hasBadge then

text.Text = “achieved”

else

text.Text = “not achieved”

end

You don’t own the badge correct?

And no, it’s not deleted because I was able to get it, but even before I got it, it said that I had obtained it

Remove that, make your TextLabel say not achieved.

If it doesn’t work still, look at the documentation.

His badge is deleted? Wdym how is he able to use it in game then