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

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

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)

1 comment

0

If it's for a game pass you use :PromptGamePassPurchase()

1 answer

✓ Accepted answer

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.

4 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

1

Edited now.

0

Much better

0

Thank you for the great response.

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