Replace the code inside the enabled LocalScript under the “Open” TextButton with this:
local GAME_PASS_ID = 5694417
local playersService = game:GetService("Players")
local marketPlaceService = game:GetService("MarketplaceService")
local localPlayer = playersService.LocalPlayer
local openButton = script.Parent
local photoOptionGui = openButton.Parent
local purchaseFrame = photoOptionGui.Purchase
local mainFrame = photoOptionGui.MainFrame
-- get ownership status.
local isSuccessful, isOwner = pcall(marketPlaceService.UserOwnsGamePassAsync, marketPlaceService, localPlayer, GAME_PASS_ID)
if not isSuccessful then return end
if isOwner then
mainFrame.Visible = true
purchaseFrame.Visible = true
The code isn’t fully tested, as game pass ownership cannot be checked in an unpublished game. Let me know if something goes wrong.
I also noticed some small issues with the other code:
- Global variables are used instead of local variables, which are faster to get.
RBXScriptSignal:connect, which is deprecated, is used instead of
GuiButton.MouseButton1Down is used instead of
GuiButton.Activated, which works across all platforms.
- The DataModel is indexed to get services instead of
ServiceProvider:GetService, which uses class name rather than name and is encouraged by Roblox.