How to make a button if you click on it a gamepass pops up and if u purchase it you can click it to access a different ui

I need help for this literally i need help!!!

1 Like

I have something very similar for my game;

basically just do an if statement, check if the player has the gamepass through MarketplaceService, and if they dont, make them purchase it.

here are some fragments of my code (very bad lol)

local mps = game:GetService("MarketplaceService")
local tps = game:GetService("TeleportService")
local rs = game:GetService("ReplicatedStorage")
local event = rs.remotes.event
local event2 = rs.remotes.buy

game.Players.PlayerAdded:Connect(function(plr)
	if mps:UserOwnsGamePassAsync(plr.UserId, 872461568) or IsPlayTester(plr) then
		--print("player", plr.Name, "owns early access")
		event:FireClient(plr)
	else
		--print("player", plr.Name, "does not own early access")
		event2:FireClient(plr)
		event2.OnServerEvent:Connect(function(plr)
			game:GetService("MarketplaceService"):PromptGamePassPurchase(plr, 872461568)
			
			mps.PromptGamePassPurchaseFinished:Connect(function(plr, purchasedPassID, success)
				if success and purchasedPassID == 872461568 then
					print("player", plr.Name, "purchased early access")
					event:FireClient(plr)
				end
			end)
		end)
	end
end)
1 Like