Roblox script only working in Alone Playtest, not in game or in Team Test

Here is the script that Is only working in Alone Playtest, and not in game or Team Test

local coinsProductIDs = 
	{
		[1910234500] = 5,
		[1910234818] = 20,
		[1910281268] = 50,
		[1910281559] = 100,
		[1910281801] = 300,
	}

local ToolProductIDs = 
	{
		[1924377857] = game.ReplicatedStorage.RobuxTools["Robux Apple"],
		[1924532500] = game.ReplicatedStorage.RobuxTools["Robux Sword"],
		[1924591877] = game.ReplicatedStorage.RobuxTools["Robux Cola"],
		[1924616987] = game.ReplicatedStorage.RobuxTools["Robux Potion"],
	}

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

mps.ProcessReceipt = function(purchaseInfo)
	local plrPurchased = game.Players:GetPlayerByUserId(purchaseInfo.PlayerId)

	if not plrPurchased then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	-- Check if the purchased product is for coins
	for productID, coinsGiven in pairs(coinsProductIDs) do
		if purchaseInfo.ProductId == productID then
			plrPurchased.leaderstats.Gold.Value = plrPurchased.leaderstats.Gold.Value + coinsGiven
			game.ReplicatedStorage.BoughtGold:FireAllClients(plrPurchased.Name, coinsGiven)
			return Enum.ProductPurchaseDecision.PurchaseGranted
		end
	end

	-- Check if the purchased product is for a tool
	for productID, Tool in pairs(ToolProductIDs) do
		if purchaseInfo.ProductId == productID then
			local newTool = Tool:Clone()
			newTool.Parent = plrPurchased.Backpack
			game.ReplicatedStorage.BoughtGold:FireAllClients(plrPurchased.Name, Tool.Name)
			return Enum.ProductPurchaseDecision.PurchaseGranted
		end
	end

	-- Custom handling for product ID 1924701813
	if purchaseInfo.ProductId == 1924701813 then
		plrPurchased.Character.Humanoid.Health = 100
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end

	-- Custom handling for product ID 1924701658
	if purchaseInfo.ProductId == 1924701658 then
		local items = game.ReplicatedStorage.RobuxTools:GetChildren()
		local toolItems = {}

		for _, item in pairs(items) do
			if item:IsA("Tool") then
				table.insert(toolItems, item)
			end
		end

		if #toolItems > 0 then
			local randomTool = toolItems[math.random(1, #toolItems)]:Clone()
			randomTool.Parent = plrPurchased.Backpack
		end

		return Enum.ProductPurchaseDecision.PurchaseGranted
	end

	-- Custom handling for product ID 1924701121
	if purchaseInfo.ProductId == 1924701121 then
		local items = game.ReplicatedStorage.ChestTools:GetDescendants()
		local toolItems = {}

		for _, item in pairs(items) do
			if item:IsA("Tool") then
				table.insert(toolItems, item)
			end
		end

		if #toolItems > 0 then
			local randomTool = toolItems[math.random(1, #toolItems)]:Clone()
			randomTool.Parent = plrPurchased.Backpack
		end

		return Enum.ProductPurchaseDecision.PurchaseGranted
	end


	-- If the product is neither for coins, a tool, nor any of the custom products
	return Enum.ProductPurchaseDecision.NotProcessedYet
end


Thank you.

1 Like

It sounds like it may be a client/server replication error. Can you please specify the location of the script in the explorer, and what type of script it is (Localscript, Script, ModuleScript).

Yes, thanks for replying, it is a Script in serverscriptservice, not a localscript.

Ive tried adding prints, ive come to the conclusion that the “mps.ProcessReceipt = function(purchaseInfo)” part is just not functioning at all during a team test or actual game, but during a test it works.

It seems that this may be a long-lasting unresolved bug:
ProcessReceipt not working in Team Testing

1 Like

Oh my gosh, I just fixed it, it’s taken up my entire night dude, thanks so much, that thing you linked helped. Thanks.

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