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
--// 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.
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
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.
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
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.