So basically I want it to prompt a game pass purchase then simply change a value. When it prompts the game pass purchase it prompts some random game pass and does not work? Please help me, Here is the code!
local id = 5242880
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,id) then
game.Workspace.Middle.Value = true
else
game:GetService("MarketplaceService"):PromptPurchase(player, id)
script.Parent.Parent.Status.Text = "In order to be a Middle rank you need to buy the gamepass."
wait(7)
script.Parent.Parent.Status.Text = ""
end
end)

3 comments
You use PromptGamePassPurchase to prompt game pass purchases.
Additionally, you should check if they own the game pass on the server, using remotes, as well as using UserOwnsGamePassAsync instead of PlayerOwnsAsset as game passes are no longer assets. They are now their own category, and the arguments to UserOwnsGamePassAsync are: UserId, GamePassId. Instead of the player object you'd pass their UserId.
On line 7, instead of "game:GetService("MarketplaceService"):PromptPurchase(player, id)", do game:GetService("GamepassService"):PromptGamePassPurchase(player, id)