[SOLVED] Gui won't appear after buying a dev product

I located the issue, the server script was set on legacy well not by me(not the main issue). My sister was on my computer before when I was doing something. She might’ve done it but thanks for all the help guys! [EDITED: The main issue has been fixed. Thank you, Cunly, oofman9009 and 12345koip.]

2 Likes

Great work finding the issue! Good luck on your game. :blue_heart: :clap:

1 Like

Hey! Sorry for the late reply. Here is a way to implement ProcessReceipt!

--Server script in ServerScriptService

local mps = game:GetService("MarketplaceService")
local players = game:GetService("Players")

local productFunctions = {} --this will hold the dev product functions

productFunctions[YourProductIdHere] = function(player) --put your product ID in the square brackets
    --your code that you want to run when the player buys the product goes here
    return true
end

--now, we need to process it
local function processReceipt(info)
    --get the player and the handler
    local player = players:GetPlayerByUserId(info.PlayerId)
    local handler = productFunctions[info.ProductId]

    --run in protected mode just in case something goes wrong
    local success, result = pcall(handler, player)

    if success then --purchase successful. Let Roblox know it has been handled.
        return Enum.ProductPurchaseDecision.PurchaseGranted
    else --something went wrong. Let Roblox know so it can try again when the player next joins the game.
        warn(result)
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end
end

--set the callback, which can only be done once in a server script
mps.ProcessReceipt = processReceipt
1 Like

I have tested this out, it’s way more responsive and isn’t such a mess as the other scripts thank you.

1 Like

Hey, I know that I said everything went right but now another issue is because my local script won’t make the button disappear for 30 seconds after buying the product.

local plrs = game:GetService("Players")
local mps = game:GetService("MarketplaceService")

local button = script.Parent
local duplicants = game.Workspace.duplicants

button.Visible = false

duplicants.ChildAdded:Connect(function(part)
	if part:IsA("Part") then
		task.wait(8)
		button.Visible = true
	end
end)

button.MouseButton1Click:Connect(function()
	local productId = 1839490031
	mps:pro(plrs.LocalPlayer, productId)
	task.wait(0.1)
	if Enum.ProductPurchaseDecision.PurchaseGranted then
		button.Visible = false
		task.wait(30)
		button.Visible = true
	else
		button.Visible = false

	end
end)

I definitely have something wrong here but I tried my best to make it work.

Not quite sure what you’re trying to do here.

All you need to do is prompt the purchase on the client, and let the server handle the receipt. You could fire a remote from the server to let the client know if it was succeessful or not.

local function prompt()
    mps:PromptProductPurchase(players.LocalPlayer, productId)
end

button.MouseButton1Click:Connect(prompt)

Oh I wanted to write PromptProductPurchase, and when purchase was granted the button should go invisible and wait for 30 seconds until it comes back.

No, as in mps:pro(). It’s not a valid method of MarketplaceService. Like I said, you can use a remote from the server.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.