How do i fix "UserHasBadgeAsync failed due to empty response"

i have this error that i keep getting for, How do I fix this issue,

Code:

local BadgeId = 83742974923742333344234234234234242

local Works, Error = pcall(function()
	if BadgeService:UserHasBadgeAsync(Player.UserId, BadgeId) then
		print("Badge Owned")
	else
		print("Badge Not Owned")
	end
end)

if not Works then
	print("Failed To Load Badge Status, " .. Error )
end

AAAA I cant fix this help my 3 braincel

ok im just gonna add a long debounce now

local Debounce = 1000
local OnDebounce = false

local function AddBadge(BadgeId)
	local Works, Error = pcall(function()
		if BadgeService:UserHasBadgeAsync(Player.UserId, BadgeId) then
			print("Badge Owned")
		else
			print("Badge Not Owned")
		end
	end)
	
	if not Works then
		print("Failed To Load Badge Status, " .. Error )
	end
end
		

Buttons.MouseButton1Down:Connect(function()
	if OnDebounce == false then
		OnDebounce = true	
		
		AddBadge(Buttons.BadgeId.Value)
		
		wait(Debounce)
		OnDebounce = false
	end
end)

Your badge doesn’t even exist? I think you put the wrong id there

yes i have the right badge id but I just changed it

Are you showing the entire script? Because i don’t think so. And you have to give people their badges on the Server, use remote events for that.

local ProximityPrompt = script.Parent.ProximityPrompt
local BadgeService = game:GetService("BadgeService")

local Colors = {
	Gray = {Color3.fromRGB(30, 30, 30)},
	Green = {Color3.fromRGB(0, 204, 6)},
	Red = {Color3.fromRGB(214, 0, 7)}
}

ProximityPrompt.Triggered:Connect(function(Player)
	if game.Players:FindFirstChild(Player.Name) then
		local StarterGui = Player.PlayerGui
		
		local BadgesOwned = StarterGui.BadgesOwned
		local SelectedBadge = BadgesOwned.Frame.SelectedBadge
		local Badges = BadgesOwned.Frame.Badges
		
		if BadgesOwned.Enabled == false then
			BadgesOwned.Enabled = true
		end

		local LastButton
		
		local Debounce = 1
		local OnDebounce = false

		local function AddBadge(Button)
			if LastButton ~= Button and Player and game.Players:FindFirstChild(Player.Name) then
				SelectedBadge.BadgeIcon.Image = "rbxthumb://type=BadgeIcon&id=".. Button:FindFirstChild("BadgeId").Value .."&w=150&h=150"
				SelectedBadge.BadgeName.Text = Button:FindFirstChild("Name").Value

				SelectedBadge.BadgeStatus.BackgroundColor3 = Colors.Gray[1]
				SelectedBadge.BadgeStatus.BadgeStatusText.Text = "Loading Badge Status..."

				LastButton = Button

				local Works, Results = pcall(function()
					if BadgeService:UserHasBadgeAsync(Player.UserId, Button:FindFirstChild("BadgeId").Value) then
						SelectedBadge.BadgeStatus.BackgroundColor3 = Colors.Green[1]
						SelectedBadge.BadgeStatus.BadgeStatusText.Text = "Badge Owned"
					else
						SelectedBadge.BadgeStatus.BackgroundColor3 = Colors.Gray[1]
						SelectedBadge.BadgeStatus.BadgeStatusText.Text = "Badge Not Owned"
					end
				end)

				if not Works then
					SelectedBadge.BadgeStatus.BackgroundColor3 = Colors.Red[1]
					SelectedBadge.BadgeStatus.BadgeStatusText.Text = "Failed To Load Badge Status, " .. Results
				end
			end
		end


		for i, Buttons in pairs(Badges:GetChildren()) do
			if Buttons:IsA "ImageButton" then
				if Buttons:FindFirstChild("BadgeId") then
					Buttons.Image = "rbxthumb://type=BadgeIcon&id=".. Buttons:FindFirstChild("BadgeId").Value .."&w=150&h=150"
					
					Buttons.MouseButton1Down:Connect(function()
						if OnDebounce == false then
							OnDebounce = true
							
							AddBadge(Buttons)
							
							wait(Debounce)
							
							OnDebounce = false
						end
					end)
				end
			end
		end
	end
end)

here’s 99% of the script then

UserHasBadgeAsync can only be called by a server script

I moved the script to “ServerScriptService” and its still giving the same error

thats weird it could be something to do with roblox not totally sure tbh

the bug got fixed when player dies whatta

edit, nvm

I was firing UserHasBadgeAsync every time the player clicks the button, And the MouseButton connection fires every time the ProximityPrompt gets triggered, And the GUI has “ResetOnSpawn” enabled that’s why

oh no did I bump