Need help with Developer Products

So in my game i was making a Developer Product. My idea was to click on the brick and then it pops up with a Developer Product to buy but it just keeps giving me errors. do you have the solution?

If you need the game link:Stud Place - Roblox

i guess use a clickdetector and then you can prompt it

I tried that already but thanks for trying to help!

Can you please send what you coded to help identify what exactly in the code is causing the error? Kinda hard to help you figure out where the problem is when we don’t know how you exactly tried to script it. Thx!

What error does it come up with and what’s the code. If we don’t know this, we won’t know the problem and we won’t be able to fix it.

local service = game:GetService(‘MarketplaceService’)

local id = 19189499

local player = script.Parent.Parent

local part = game.Workspace.Part

part.ClickDetector.MouseClick:connect(function()

service:PromptProductPurchase(player, id)

end)

The script you use is probably somewhere beneath the player and a local script. You can get the player with MouseClick event too.

Put that in a regular script under the part.

local MarketplaceService = game:GetService("MarketplaceService")
local ProductId = 19189499
local Part = script.Parent

Part.ClickDetector.MouseClick:Connect(function(player)
    MarketplaceService:PromptProductPurchase(player, ProductId)
end)

So some the problem with your script is that you called out variable player to be “local player = script.Parent.Parent” which shouldn’t be. Your better off referencing player in your MouseClick function where it will detect if a player clicks your part.

The script that I would recommend would be similar for what ProBaturay suggested above.

-- Calls out service responsible for in-game transactions
local ms = game:GetService("MarketplaceService")

local productId = 19189499
local cd = script.Parent:FindFirstChild("ClickDetector")

-- Function: When player clicks the part, clickdetector will trigger and prompt product purchase
cd.MouseClick:Connect(function(plr)
    -- plr references the specific player purchasing the product and productId is the ID of the product
    ms:PromptProductPurchase(plr, productId) 
end)

This should be the script you are looking for. Don’t forget to add a ClickDetector inside the part that players will click to purchase the product (No need to rename ClickDetector, can leave it as is).

Hope this helps.

2 Likes