So I made a script, and I need it to do something. Heres the script.
button.MouseButton1Down:Connect(function()
end)
Now, inside there, I need it to prompt to buy a certain Developer Product, not gamepass.
I then need it to make sure they actually bought it, and then give them the coins.
I am not sure how to prompt Developer Products. Is it the same as gamepasses? And how do I check that they bought it?
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productID = 0000000 -- Change this to your developer product ID
-- Function to prompt purchase of the developer product
local function promptPurchase()
local player = Players.LocalPlayer
MarketplaceService:PromptProductPurchase(player, productID)
end
The Local Script to prompt the devProduct Purchase can be set like this
local Player = game.Players.LocalPlayer
local MarketPlaceService = game:GetService("MarketplaceService")
local DevProductID = script.Parent.DevProductID.Value
local PurchaseButton = script.Parent
PurchaseButton.MouseButton1Click:Connect(function()
MarketPlaceService:PromptProductPurchase(Player, DevProductID)
end)
You can have a value inside the buy button like me or just put the value its self on “local DevProductID = script.Parent.DevProductID.Value” and then use the MarketPlaceService and Promt the product purchase.
ProcessReceipt gets called when the player purchases the product so if you have that defined then it’s already handled for you. If you have a client-side effect that’s dependent on the prompt being closed then you can use PromptProductPurchaseFinished, but NEVER USE IT TO HANDLE PRODUCT PURCHASES. ProcessReceipt has special requirements to successfully process a product purchase (returning a ProductPurchaseDecision enum).
I like to keep mine like this:
It has a IntValue inside the button and the IntValue is the Dev Product Id.
local Player = game.Players.LocalPlayer
local MarketPlaceService = game:GetService("MarketplaceService")
local DevProductID = script.Parent.DevProductID.Value
local PurchaseButton = script.Parent
PurchaseButton.MouseButton1Click:Connect(function()
MarketPlaceService:PromptProductPurchase(Player, DevProductID)
end)