Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I modify this script to work with the new game-pass ids?

Asked by
Tryphas -3
5 years ago

ROBLOX switched gamepasses from using asset ids to using their very own game-pass ids so I'm wondering what I have to change in this script to fix it, thanks.

local player = game.Players.LocalPlayer
local id = ***asset id here***
script.Parent.MouseButton1Down:connect(function()
    game:GetService("MarketplaceService"):PromptPurchase(player, id)
end)
0
If it's for a game pass you use :PromptGamePassPurchase() User#24403 69 — 5y

1 answer

Log in to vote
0
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

Problem

The problem is: You are using MarketPlaceService:PromptPurchase(player,GamePassId), you need to useMarketPlaceService:PromptGamePassPurchase(player,GamePassId) for gamepasses. i only know the MarketPlaceService:PromptPurchase() is for buy roblox items, the MarketPlaceService:PromptGamePassPurchase() is for buy GamePasses from games.

PromptPurchase: Used to prompt a user to purchase an item with the given assetId.


PromptGamePassPurchase: Used to prompt a user to purchase a game pass with the given assetId.

Correction of problems/recommendations

For first, :connect is deprecated, you need to use :Connect Also you can use MouseButton1Click instead of MouseButton1Down but you can use the MouseButton1Down if you like.

MouseButton1Down have 2 arguments, this arguments is mouse position(only x,y):

script.Parent.MouseButton1Down:Connect(function(x,y)
    print("Pos: x:" .. x .. " y:" .. y)
end)

MouseButton1Click no have arguments, this return nil

script.Parent.MouseButton1Click:Connect(function(arg1)
    print(tostring(arg1)) -- This return " nil "
end)

Now for make this to buy a gamepass change PromptPurchase to PromptGamePassPurchase

Fixed script:

local player = game.Players.LocalPlayer or game:GetService("Players").LocalPlayer
local id = 0 -- Id here
script.Parent.MouseButton1Click:Connect(function()
    game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id)
end)

Wiki pages:

PromptGamePassPurchase

MouseButton1Click


Solved your problems? put in title [SOLVED] or accept a answer.

Hope it helped, Errors? tell-me on comments.

0
This answer is simply "do this". But why? Why should OP use the latter over the former? Or the former instead of the latter? "because I say so". Even with the wiki pages you should give some explanation as well User#24403 69 — 5y
1
Edited now. yHasteeD 1819 — 5y
0
Much better User#24403 69 — 5y
0
Thank you for the great response. Tryphas -3 — 5y
Ad

Answer this question