Fire Alarm Not working!

Whenever I buy myself this dev product, the fire alarm doesn’t activate!

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

local devProductId = 3279896787 
local proximityPrompt = script.Parent
local lightsignal = workspace:WaitForChild("Fire Alarm"):WaitForChild("Lightsignal")

local purchaseRequests = {} -- tracks who requested purchase

-- Handle Proximity Prompt Trigger
proximityPrompt.Triggered:Connect(function(player)
	if lightsignal.Value == 1 then
		player:Kick("The fire alarm is already active!")
		return
	end

	purchaseRequests[player.UserId] = true
	MarketplaceService:PromptProductPurchase(player, devProductId)
end)

-- Handle Receipt
MarketplaceService.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == devProductId then
		local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
		if player and purchaseRequests[player.UserId] then
			purchaseRequests[player.UserId] = nil

			lightsignal.Value = 1
			print("Fire alarm activated for player:", player.Name) -- Added print statement for debugging

			task.delay(120, function()
				lightsignal.Value = 0
				print("Fire alarm deactivated") -- Added print statement for debugging
			end)

			return Enum.ProductPurchaseDecision.PurchaseGranted
		else
			warn("Player not found or purchase request not found for PlayerId:", receiptInfo.PlayerId) -- Debugging
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
	end

	return Enum.ProductPurchaseDecision.NotProcessedYet
end```

Do you have any other scripts which are involved in process receipt. From memory, I think there can only be a single event connected to MarketplaceService.ProcessReceipt

I think so, I’m using this free model donator board.

MarketplaceService.ProcessReceipt is only called by Roblox in a server-side Script, not in a LocalScript, nor from scripts in workspace or GUI objects.

Also make sure that the game is published, it could be that ProcessReceipt isn’t getting called.
And that MarketplaceService.ProcessReceipt is only set once in the entire game otherwise it could be overlapping and cause it not to work.

Make sure lightsignal is also an IntValue.

(Make sure the script is placed in ServerScriptService)
I’d say give this a try:

-- Ignore the variables if you have them already set up.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")

local devProductId = 3279896787
local lightsignal = Workspace:WaitForChild("Fire Alarm"):WaitForChild("Lightsignal")
local proximityPrompt = Workspace:WaitForChild("Fire Alarm"):WaitForChild("ProximityPrompt")

local purchaseRequests = {}

proximityPrompt.Triggered:Connect(function(player)
	if lightsignal.Value == 1 then
		player:Kick("The fire alarm is already active!")
		return
	end

	purchaseRequests[player.UserId] = true
	MarketplaceService:PromptProductPurchase(player, devProductId)
end)

MarketplaceService.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == devProductId then
		local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)

		if player and purchaseRequests[player.UserId] then
			purchaseRequests[player.UserId] = nil

			lightsignal.Value = 1
			print("Fire alarm activated for player:", player.Name)

			task.delay(120, function()
				lightsignal.Value = 0
				print("Fire alarm deactivated")
			end)

			return Enum.ProductPurchaseDecision.PurchaseGranted
		else
			warn("Purchase received but player not found or no pending request for:", receiptInfo.PlayerId)
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
	end

	return Enum.ProductPurchaseDecision.NotProcessedYet
end
1 Like

Everything is correct. My donator board is the problem and it is too complex in terms of scripting.