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.