✓ 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))
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
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.
1 comment
If it's for a game pass you use :PromptGamePassPurchase()