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

PromptPurchase script not giving player a PromptPurchase?

local button = script.Parent
local devid = 441671993

button.MouseButton1Click:Connect(function(player)
	game:GetService("MarketplaceService"):PromptPurchase(player, devid)
end)

3 comments

0

If it's a gamepass, use PromptGamePassPurchase. If it's a dev product, use PromptProductPurchase

0

i was using that before, thats weird

2

The MouseButton1Click event has no parameters, so “player” would return nil. Fortunately, you can use game.Players.LocalPlayer instead to get the player, assuming you’re using a local script.

1 answer

✓ Accepted answer

Your script should have "PromptGamepassPurchase" or "PromptProductPurchase" depending on if it is a gamepass or a dev product. Here is your fixed script: Gamepass script:

local button = script.Parent
local devid = 441671993

button.MouseButton1Click:Connect(function(player)
    game:GetService("MarketplaceService"):PromptGamePassPurchase(player, devid)
end)

Dev Product:

local button = script.Parent
local devid = 441671993

button.MouseButton1Click:Connect(function(player)
    game:GetService("MarketplaceService"):PromptProductPurchase(player, devid)
end)

Accept this answer if it helped you!

1 comment

0

it does work accept it

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