I’ve been trying to create a morph outfit inventory for a while (background: players can buy different character images). If the player has a certain game pass, a certain image button becomes visible. The problem is that the script doesn’t work and the image button isn’t displayed (I have the feeling that this is because it’s in a frame in the UI grid layout in the screenGui). Does anyone know the solution?
local BadgeService = game:GetService(“BadgeService”)
local Players = game:GetService(“Players”)
local GamepassID = 123456789 – I will change the ID soon
local function checkBadge(player)
local success, hasBadge = pcall(function()
return BadgeService:UserHasBadgeAsync(player.UserId, badgeID)
end)
if success and hasBadge then
local playerGui = player:WaitForChild("PlayerGui")
local screenGui = playerGui:FindFirstChild("OpenFrame")
if screenGui then
local haveBadgeFrame = screenGui:FindFirstChild("havebadge")
if haveBadgeFrame then
haveBadgeFrame.Visible = true
end
end
else
warn("Failed to check badge or player does not have the badge")
end
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
checkBadge(player)
end)
end)