(SOLVED) help with GamePass only gui!

I have a gui text button that prompts a gamepass purchase but I want it to open a frame if the player owns the gamepass here is my script:

local plr = game.Players.LocalPlayer

local button = script.Parent

local MarkerPlaceService = game:GetService("MarketplaceService")

local gamepass_id = 39692796

script.Parent.MouseButton1Click:Connect(function()

MarkerPlaceService:PromptGamePassPurchase(plr,gamepass_id)

end)

Thanks.

1 Like

is the local script right under the button?

And does the purchaseprompt appear at all?

1 Like

yeah

(I have to be over a character limit for this comment)

local players = game:GetService("Players")
local MPS = game:GetService("MarketplaceService")
local passId = 2125638306 


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if MPS:UserOwnsGamePassAsync(player.UserId,passId) then
			local UI = script.OnlyGamepass:clone()
			UI.Parent = player.PlayerGui
		end
	end)
end)

Explanation:

We use PlayerAdded event to fire whenever a player joins the game, we then want to use CharacterAdded [not always necessary], this will make sure to run a code whenever the chararacter reloads.

Now, make sure you have a UI under a script in ServerScriptService

image

[Your local script is good and working fine]

4 Likes

If it helped, make sure to mark it as a solution :slight_smile:

Best of luck :slight_smile:

How would I make it appear when I click a text button I already have one in starter gui, Thanks

Then just simply access to thag TextButton from the script I sent above and visible it only to that player.

Why not use β€˜ResetOnSpawn’ instead of that? And if it’s to see if their gamepass gets added, why not use β€˜PromptGamePassPurchaseFinished’?

Because that way is easier, and more familiar to people.