local player = game.Players.LocalPlayer
local Market = game:GetService("MarketplaceService")
id = 9507679

script.Parent.MouseButton1Click:Connect(function()
	Market:PromptGamePassPurchase(player,id)
	print("Bought!")
end)

This prompts the purchase.

local MPS = game:GetService("MarketplaceService")
game.Players.PlayerAdded:connect(function(plr)
 plr.CharacterAdded:connect(function(chr)
  repeat wait() until chr.Humanoid
  chr.Humanoid.Died:connect(function()
	if MPS:UserOwnsGamePassAsync(plr.UserId,9507679) then
   plr.LoadCharacter()
	end
  end)
 end)
end)

This is one of the functions, and the other one:

local deathMeassages = {
-- too long to show
-- plus not relevant
}

local frame = script.Parent.DeathFrame
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local MPS = game:GetService("MarketplaceService")
local Id = 9507679
frame.Visible = false
character:WaitForChild('Humanoid').Died:Connect(function()
	if not MPS:UserOwnsGamePassAsync(player.UserId,Id) then -- if user owns pass, skip
	local i = math.random(1,56)
	frame.DeathText.Text = deathMeassages[i]
	frame.Visible = true
	repeat wait() until character.CharacterAdded
	frame.Visible = false
	end
end)