Prompt developer product not working on Surface Gui

My script to prompt a purchase through a SurfaceGui is not working. There are no errors or anything as shown in the video. My scripts and the script locations are below.
I can’t figure this out so any help will be useful.

The script is supposed to go in this order.
Player clicks button → Prompts purchase → If player purchases continue (if not nothing happens) → Fire Server event to a script → Fire in fireplace & smoke enables → Wait(5) → Disable fire and smoke

LocalScript ( Inside WasteMoney, Ui, SurfaceGui, backroundFrame, BurnHandler )
image

--// Configure
local id = 1236620209

--// Variables
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local purchaseButton = script.Parent.purchaseButton
local title = script.Parent.Title
local subtitle = script.Parent.subtitle
local thanks = script.Parent.thanks

--// Prompt
purchaseButton.MouseButton1Click:Connect(function(promptPurchase)
	local player = Players.LocalPlayer
	MarketplaceService:PromptProductPurchase(player, id)
end)

These are the scripts & the event.
image

CheckFireProduct

--// Variables
local MarketplaceService = game:GetService("MarketplaceService")
local id = 1236620209

--// Main
local function processReceipt(receiptInfo)
	if receiptInfo.ProductId == id then
		local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
		if not player then
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
		game.ReplicatedStorage.StartFirePlace:FireServer()
	end
end

FireProduct

local WasteMoney = game.Workspace:WaitForChild("WasteMoney")
local fire = WasteMoney.fire
local smoke = WasteMoney.smoke
local ui = WasteMoney.Ui

game.ReplicatedStorage.StartFirePlace.OnServerEvent:Connect(function()
	wait(1)
	print("Get ready! Someone wasted their money!")
	fire.Fire.Enabled = true
	wait(0.5)
	smoke.Smoke.Enabled = true
	print("Wow ! Look at those effects!")
	wait(5)
	fire.Fire.Enabled = false
	wait(0.5)
	smoke.Smoke.Enabled = false
end)

Local scripts don’t execute when parented to the workspace. Consider moving the script to StarterPlayerScripts and referencing the SurfaceGui from there.

you can’t put local scripts inside workspace, they wont work. Change the parent of the surface gui to starter gui, then set the surface gui’s adornee to the part. Or you could re-write the script, but the 1st method is easier imo

Hi! Thanks for being quick! I did what you said but the fire and smoke still wont appear?

I know a lot of people said this but, LocalScripts do not work in Workspace. You can use RemoteEvents to fire to a LocalScript.

You can’t fire the server from the server itself with a RemoteEvent instance. You’ll need to make use of a BindableEvent instead, or just merge the two scripts.

https://developer.roblox.com/en-us/api-reference/class/BindableEvent

I read over it, I’m confused on how to implement this into the script? Would I just replace the RemoteEvent with a BindableEvent?

Yes and switch “FireServer()” for “Fire()” and “OnServerEvent” for “Event”.

Hm, did everything you said and double checked it. Still not working

You must have something incorrectly referenced/setup then, I’d rather not attempt to debug it on your behalf.

local MarketplaceService = game:GetService("MarketplaceService")
local id = 1236620209
local WasteMoney = game.Workspace:WaitForChild("WasteMoney")
local fire = WasteMoney.fire
local smoke = WasteMoney.smoke
local ui = WasteMoney.Ui

--// Main
local function processReceipt(receiptInfo)
	if receiptInfo.ProductId == id then
		local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
		if not player then
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
		wait(1)
		print("Get ready! Someone wasted their money!")
		fire.Fire.Enabled = true
		wait(0.5)
		smoke.Smoke.Enabled = true
		print("Wow ! Look at those effects!")
		wait(5)
		fire.Fire.Enabled = false
		wait(0.5)
		smoke.Smoke.Enabled = false
	end
end

Just merge the two scripts.

I looked over all of it again and still can’t figure out any errors. I also tried the code you posted here and put it into the script “CheckFireProduct” inside ServerScriptService.
No errors appear in the console.

Just realized you forgot to assign the function to the “ProcessReceipt” callback of the “MarketplaceService”.

MarketplaceService.ProcessReceipt = processReceipt

Tried that as shown in this video. (I think i did it right)

Woah is that Clash Royale? Not about the topic, but Great Game Topic!

1 Like

I mean at the end of the script, for example.

local function processReceipt(receiptInfo)
	--code here
end

MarketplaceService.ProcessReceipt = processReceipt
1 Like

It worked!! It’s finally worked! Thank you so much for your help! I’ll mark this as the solution.