How to Prompt a Developer Product Purchase

Hello!
I have been struggling for so long now. Please help me :slight_smile:
I have created a small purchasing stand for my game. I want it to prompt purchase one of my developer products.
How would I go about this? I have tried free models, Roblox Developer website, youtube videos, and it still never seems to work.

PLEASE HELP :frowning:

image
image

Try this page:

1 Like

You can’t use game.Players.LocalPlayer inside of scripts, and unfortunately, script.Parent.MouseButton1Click:Connect(function(h) doesn’t register who clicked it. I’d recommend you to create a new part, insert a ClickDetector to it, and scale it down to an appropriate size that fits as a replacement. After, insert a script into the ClickDetector, and use the code:

--[ Variables
local cd = script.Parent
local mps = game:GetService("MarketplaceService")
--[ Setup
cd.MouseClick:Connect(function(plr)
	mps:PromptPurchase(plr, 000)
end)

Ok, you have to first put a click detector inside your button that you want the player to click.
Then you need to use marketplaceservice to prompt a product purchase.
Put a script inside the part that has the clickdetector.

local MarketPlaceService = game:GetService("MarketPlaceService") -- This service is used for prompting purchases or checking if a player has purchased items.
Script.Parent.ClickDetector.MouseClick:Connect(function(player) -- Puts a player parameter in this event so that we can access the player who clicked
        MarketPlaceService:PromptProductPurchase(player.UserId, YourDevProductID) -- This prompts a purchase for the player who clicks,
end)

Hope this helped!

2 Likes

Just switch the “Script” to a “LocalScript”.
The code is fine, even though I wouldn’t say it’s an efficient way to do this, but it works fine.

Edit: I just realized SurfaceGui is not under the PlayerGui, so what I would do is put the LocalScript under the Player directory and change the hierarchy in the code to match the new position of the TextButton.

Forgot to mention this: you should move the SurfaceGui under the PlayerGui as well, you can’t interact with it otherwise.

Insert a Click Detector, and use the built-in function MouseClick, which is used for Click Detectors, also this script will not work unless you use a Local Script, because you can’t access the “Local Player” from a regular Script.
Forgot to mention this, but you need to put the Click Detector inside the text button.