Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Not sure how to make this gamepass prompt work? No errors and just not working!

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

0

You use PromptGamePassPurchase to prompt game pass purchases.

0

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.

0

On line 7, instead of "game:GetService("MarketplaceService"):PromptPurchase(player, id)", do game:GetService("GamepassService"):PromptGamePassPurchase(player, id)

1 answer

I have had problems in the past with local variables. Change local is to just id to make it global. They are actually faster because the script needs to read each letter 1 by 1 so it's slow for the script. Also try not to space out the code because it has to read the spaces making it even slower and harder for the script

This discussion is preserved as it was. New answers, comments, and votes are closed.