UserOwnsGamePassAsync not working?

There are no errors in output, and the script reaches the UserOwnsGamePassAsync part but doesn’t hide the gui?

local MarketplaceService = game:GetService("MarketplaceService")

local menu = script.Parent.Parent.Parent.Parent.Parent
local controlsframe = script.Parent.Parent.Parent.Parent.Parent.Parent.ADVANCED

local Player =  game.Players.LocalPlayer
local GamepassId = 11391069

script.Parent.MouseButton1Click:Connect(function()
	menu:TweenPosition(UDim2.new(0.5, 0, 2, 0))
	
	print("tweened gui")
	
	if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
	game.StarterGui.menugui.ADVANCED.Frame.Visible = false
	
		else warn("unable to find gamepass")
		
	print("checked for gamepass")
	
	wait(0.4)
		
	controlsframe:TweenPosition(UDim2.new(0.5, 0, 0.5, 0))
	
	end
end)

its because you are changing startergui and not playergui, the children and guis in startergui get cloned to playergui, you have to change playergui

local MarketplaceService = game:GetService("MarketplaceService")

local menu = script.Parent.Parent.Parent.Parent.Parent
local controlsframe = script.Parent.Parent.Parent.Parent.Parent.Parent.ADVANCED

local player =  game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui") -- Wait for PlayerGui
local GamepassId = 11391069

script.Parent.MouseButton1Click:Connect(function()
    menu:TweenPosition(UDim2.new(0.5, 0, 2, 0))
	
	print("tweened gui")
	
	if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) and playerGui:FindFirstChild("menugui") then -- also check if menugui exists
	    playerGui.menugui.ADVANCED.Frame.Visible = false
	
	else
        warn("unable to find gamepass")
		
	print("checked for gamepass")
	
	wait(0.4)
		
	controlsframe:TweenPosition(UDim2.new(0.5, 0, 0.5, 0))
	
	end
end)
1 Like

thank you, my bad :happy2: (30chars)