Issue with displaying text if player owns a badge

Bassically I have this script that would make the text label visible if the player owns that badge but its not working

This is the script

local BadgeService = game:GetService("BadgeService")
local BadgeId = 2124623689

game:GetService("Players").PlayerAdded:Connect(function(player)
	if BadgeService:UserHasBadge(player.UserId, BadgeId) then
		script.Parent.Parent.OwnBadge1.Visible = false
	else
		script.Parent.Parent.OwnBadge1.Visible = true
	end
end)

1 gui

The OwnBadge1 Text is the text that would become visible

This is what it would look like.

If player does not own badge

1 gui3

If player owns badge

is it local script or a server script?

Its a local script its inside the text label in the screenshot

I recommend putting the script on serverscriptservice use script not local script.

alright ill try it out. thanks!

nvm ik why its not working

local BadgeService = game:GetService("BadgeService")
local BadgeId = 2124623689

game:GetService("Players").PlayerAdded:Connect(function(player)
	if BadgeService:UserHasBadge(player.UserId, BadgeId) then
		script.Parent.Parent.OwnBadge1.Visible = true
	else
		script.Parent.Parent.OwnBadge1.Visible = false
	end
end)

you set the text to visible = false if player owns badge that’s why its not working

1 Like

ooooooooooooo MY GOD how did i not realise that

wait its still not working… uhhh one sec

i recommend not using playeradded event on local script.

local BadgeService = game:GetService("BadgeService")
local BadgeId = 2124623689

local player = game.Players.LocalPlayer

if BadgeService:UserHasBadge(player.UserId, BadgeId) then
	script.Parent.Parent.OwnBadge1.Visible = true
else
	script.Parent.Parent.OwnBadge1.Visible = false
end
1 Like

that one works! thanks for helping out :smiley: