Hello, dev forum!
Today while working on a dev product store I couldn’t get a speed coil dev product receipt script to work. I am hoping to get this script to the point when a player purchases the speed coil dev product the player is granted the speed coil. Currently, after the purchase players are not granted the speed coil, nothing happens. Thank you so much for reading, below is the code!
local Marketplaceservice = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local speed = ReplicatedStorage:WaitForChild("SpeedCoil")
local product ID = 1232493084
local function processReceipt(receiptInfo)
local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
local char = game.Workspace:FindFirstChild(player.Name)
local SpeedcoilClone = speed:Clone()
SpeedcoilClone.Name = "Speedcoil"
SpeedcoilClone.Parent = char
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
-- Set callback
Marketplaceservice.ProcessReceipt = processReceipt()
1 Like
You’re parenting the tool to the player instead of their backpack try replacing
SpeedcoilClone.Parent = char
with
SpeedcoilClone.Parent = player.Backpack
Still, isn’t working, here is the updated script.
local Marketplaceservice = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local speed = ReplicatedStorage:WaitForChild("SpeedCoil")
local product ID = 1232493084
local function processReceipt(receiptInfo)
local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
local char = game.Workspace:FindFirstChild(player.Name)
local SpeedcoilClone = speed:Clone()
SpeedcoilClone.Name = "Speedcoil"
SpeedcoilClone.Parent = player.Backpack
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
-- Set callback
Marketplaceservice.ProcessReceipt = processReceipt()
1 Like
You are doing lock product Id = 1232493084
it should be local productId = 1232493084
and - you are not even using the productId meaning it doesn’t know what to sell
1 Like
You should remove the parenthesis at
Marketplaceservice.ProcessReceipt = processReceipt()
instead it should be
Marketplaceservice.ProcessReceipt = processReceipt
also you should check if the receipt product Id is equal to productId before giving them the bonus.
also change
local product ID = 1232493084
to
local productID = 1232493084
because that will cause an error.
2 Likes