Is it possible to check a badge only once?

  1. What do you want to achieve? Keep it simple and clear!
    Well, i’m making a badge with a skin award.
  2. What is the issue? Include screenshots / videos if possible!
    so, if i make a script that’s check the badge and give, will be sooo many values in the inventory. No videos and screenshots available
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Deleting the script after the check, but it’s still keep going. Yes, no solutions.

My actual script is this:

local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")

local badgeID = 2124845040

local function AlphaCarlos(player) -- alpha carlos thing
	local sucess, hasBadge = pcall(function()
		return BadgeService:UserHasBadgeAsync(player.UserId, badgeID)
	end)

	if sucess then
		print("hey")
	end

	if hasBadge then
		local a = Instance.new("StringValue")
		a.Name = "Alpha Carlos"
		a.Parent = player.SkinInventory
		print("Usuário já tem a badge #1!")
	end

	if not sucess then
		print("hi")
	end
end

Players.PlayerAdded:Connect(AlphaCarlos)

Any help is appreciated. :slightly_smiling_face:

local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")

local badgeID = 2124845040

local function AlphaCarlos(player) -- alpha carlos thing
	local sucess, hasBadge = pcall(function()
		return BadgeService:UserHasBadgeAsync(player.UserId, badgeID)
	end)

	if sucess then -- success
	   print("hey")
       if hasBadge then -- has badge
		   local a = Instance.new("StringValue")
		   a.Name = "Alpha Carlos"
           if player.SkinInventory:FindFirstChild(a.Name) then return end
		   a.Parent = player.SkinInventory
		   print("Usuário já tem a badge #1!")
	   end
    else -- not success
        print("hi")
	end
end

Players.PlayerAdded:Connect(AlphaCarlos)
2 Likes

Thanks, @Valkyrop :+1: . It worked very well!

1 Like