How to make a GUI disappear if they own a gamepass?

So I am trying to make a gamepass for beta users. That way people can still access the lobby, but not the game itself.

But I am wanting the GUI to disappear if you own the Beta pass, which allows players to play the game itself.

local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassId = 20328991
local Frame = script.Parent

	Players.PlayerAdded:Connect(function(Player) 
		if (MarketPlaceService:PlayerOwnsAsset(Player, GamepassId)) then
	Frame.Visible = false
		end
	end)

The script doesn’t work, can someone explain why it will not function properly?

You’re using PlayerOwnsAsset, when you should be using UserOwnsGamePassAsync

 local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassId = 20328991
local Frame = script.Parent

Players.PlayerAdded:Connect(function(Player) 
	if (MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId)) then
	    Frame.Visible = false
	end
end)

I get that, but it still doesn’t work.

local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassId = 20328991
local Frame = script.Parent

Players.PlayerAdded:Connect(function(Player) 
	if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
	    Player.PlayerGui.ScreenGui.Frame.Visible = true
	end
end)
1 Like

You are changing frame visibility in StarterGui you need to do it in PlayerGui

This would only be neccesary if it was coming from a script that isn’t inside the GUI or the frame, otherwise this is correct.

Why you put brackets there???

Your script doesn’t work either. Whats the issue here? Why do none of our scripts work?

Where is this script in explorer

Inside of the frame, which is inside of the ScreenGui…