I have a “Help” dev product that when bought should show a GUI which provides a clue to the user. How can I add a script to the GUI so that when the product it bought, the GUI becomes visible. Thanks
Hm I don’t really understand what do you want could you explain me detailed all I understood is: when you bought a product a gui disppears
Not what he is even aiming for, hes aiming to make the gui appear WHEN the dev product is been brought.
This script should help.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local productFunctions = {}
productFunctions[1330168572] = function(receipt, player)
gui.parent = player.Playergui --do something with the gui here
return true
end
local function processReceipt(receiptInfo)
local userId = receiptInfo.PlayerId
local productId = receiptInfo.ProductId
local player = Players:GetPlayerByUserId(userId)
if player then
-- Get the handler function associated with the product ID and attempt to run it
local handler = productFunctions[productId]
local success, result = pcall(handler, receiptInfo, player)
if success then
-- The player has received their benefits!
-- return PurchaseGranted to confirm the transaction.
return Enum.ProductPurchaseDecision.PurchaseGranted
else
warn("Failed to process receipt:", receiptInfo, result)
end
end
-- the player's benefits couldn't be awarded.
-- return NotProcessedYet to try again next time the player joins.
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Set the callback; this can only be done once by one script on the server!
MarketplaceService.ProcessReceipt = processReceipt
try researching and play around with is next time
(I’m quite sorry for the bump but it’s just to solve the issue.)
Firstly, create a new game.
Secondly, go to Monetization and create a product.
Thirdly, do this script:
local ID = "Your ID here!"
local MarketplaceService = game:GetService("MarketplaceService")
task.wait(-math.huge) -- It's negative infinity (-inf).
local GUI = game.StarterGui["Your GUI Name here!"]
GUI.Enabled = false
script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer, ID)
GUI.Enabled = true
end)
They’re asking after the dev product is been bought so We should assume they’ve already done this