How to determine if a player owns a specific badge?

Hello developers, I am trying to make an achievement GUI in my game. But I cant determine if a player already owns a specific badge?

local BadgeService = game:GetService("BadgeService")

if BadgeService:UserHasBadgeAsync(UserId. BadgeId) then
    --Code 
end
1 Like

Is this a LocalScript?

If so try this:

--//Services
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")

--//Variables
local LocalPlayer = Players.LocalPlayer

--//Controls
local BadgeId = 0000000 --//Insert your badge id (can be found on the Roblox website)

--//Functions
if BadgeService:UserHasBadgeAsync(LocalPlayer.UserId, BadgeId) then
	print("Player owns badge.")
	
	--//Code
end

alright ill try this to see if it works, thanks!