Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

i don't know the script to make a purchase button?

Asked by 5 years ago

karlo_tr10 gave me a code to increase players currency which will work with the purchase button script for Dev product. Is there a purchase script to trigger a purchase?

1
Did the solution not work? royaltoe 5144 — 5y

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

You can prompt a purchase for players to purchase a gamepass or some other dev product, but you cannot force someone to purchase a the product. That is up to them.

Although, if you want to bring up the purchase prompt and don't know how, this is how you'd do that:

-- *****This code should be within a 'LocalScript' object****
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


--function for when the player clicks a button goes here....
    promptPurchase()
--end of button click function
Ad

Answer this question