Unable To Prompt Product Purchase

  1. What do you want to achieve?
    I’m trying to prompt a purchase using a click detector on a part.

  2. What is the issue?
    It’s not detecting a click when I click my mouse.

  3. What solutions have you tried so far?
    I tried adding a print statement after the click function but nothing printed.

local Players = game:GetService("Players")
local Player = Players.LocalPlayer

local marketPlaceService = game:GetService("MarketplaceService")

local clickDetector = script.Parent:WaitForChild("Click")

clickDetector.MouseClick:Connect(function()
	marketPlaceService:PromptProductPurchase(Player, 4776519379)
end)

It’s in a part that I placed in workspace

You cant access the LocalPlayer in the workspace, so you need another way to get the player that clicked the part, luckily the clickDetector.MouseClick event returns player that clicked the part so what you can do is this instead:

local Players = game:GetService("Players")

local marketPlaceService = game:GetService("MarketplaceService")

local clickDetector = script.Parent:FindFirstChild("Click") or script.Parent:WaitForChild("Click")

clickDetector.MouseClick:Connect(function(Player)
	marketPlaceService:PromptProductPurchase(Player, 4776519379)
end)

It still doesn’t seem to be working.

it should i believe as long as you are using a server script and clickDetector exists, Are there any errors?

This is just a random thought, but have you tried Publishing it, and playing the Published Game?(Not just testing it in Studio, as that’s what might be causing the issue.)

Purchases can be previewed as test purchases in studio.

Make sure that the mouseclick event is actually running by having a print above the prompt. Also, make sure your product id is valid and a part of your game.

1 Like

Okay, so I put a print into the click detector function and now it’s printing but it’s still not prompting the purchase

Like what @viindicater said, is the ID Valid ?

It is, Jean Jacket With Supreme Hoodie - Roblox

So you are using a server script with the exact code at @Jaycbee05 posted? It should work as long as id is valid, and maybe having a ProcessReceipt callback is necessary, see Developer Products | Documentation - Roblox Creator Hub

That’s not a developer product. See MarketplaceService | Documentation - Roblox Creator Hub

1 Like

Ah, ProductPurchase fixed it. Thanks

I’ve never used third party products but I think this property of workspace needs to be enabled for it to work Workspace | Documentation - Roblox Creator Hub