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)
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.
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
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)