Gamepass accessible GUI scripting issue

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want to make a GUI that is accessible to people who own a game pass. More specifically, I want to make a VIP menu that can be toggled by a button but can only be accessed by people who buy a VIP game pass.

  2. What is the issue? Include screenshots / videos if possible!
    When I try to find a script for this issue it just won’t work. The button the toggle the whole GUI doesn’t show up. What I tried doing is putting the script into ServerScriptService, and then the ScreenGUI into that script. Nothing happened.
    Current Script

game.Players.PlayerAdded:Connect(function(player)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 16868460) then
		player.PlayerGui.AnimEnabler.Enabled = true
	else
		player.PlayerGui.AnimEnabler.Enabled = false
	end
end)

VIP menu issue

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    So far I have tried to find scripts on YouTube and DevFourm, and none were successful. Any help would be appreciated

I have a feeling I placed the ScreenGUI in the wrong place but I have no idea, scripting is a whole new thing for me and I’ve been trying to impove.

Yes, you should have this GUI as an element of StarerGui, and then when a player joins Roblox’s engine will automatically handle creating copies of the GUIs in StarterGui and put them in that player’s PlayerGui folder.

Thank you for the response. I tried your idea and tested it with my main account and alt account. With my main already owning the game pass and my alt not. The VIP menu was able to be accessed on both accounts. Even when I put the screen GUI in StarterGui.

Are there any errors on your Output? Also have you set the Enabled property to false in your ScreenGui inside the StarterGui?

Insert a local script into the screengui and try this code:

local player = game.Players.LocalPlayer
local market = game:GetService("MarketplaceService")

if market:UserOwnsGamePassAsync(player.UserId, 16868460) then
	script.Parent.Enabled = true
else
	script.Parent.Enabled = false
end

Thanks for the reply, I’m happy to say this works. Thank you so much!

Your welcome. Best to use a local script in this scenario.