Hello, i am facing some issue in the script, Can you please resolve it
the error i am facing is
“Failed to process receipt: {…} ServerScriptService.PurchaseHandler:13: attempt to call missing method ‘WaitForChild’ of table”
my serverscriptservice is:
local devproIDGod = 1650733652
local devproIDsuper = 1650731748
local devproIDultra = 1650730956
local devproIDpro = 1650730083
local devproIDnoob = 1650729210
local Marketplaceservice = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productFunctions = {}
-- Gives the user 100,000 cash
productFunctions[1650729210] = function(player)
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
if cash then
cash.Value += 100000
end
end
-- Gives the user 100,000,000
productFunctions[1650730083] = function(receipt, player)
-- make it that when it is run it would give player 100000000
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
if cash then
cash.Value += 100000000
end
end
-- Gives the user 1b
productFunctions[1650730956] = function(receipt, player)
-- make it that when it is run it would give player 100000000
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
if cash then
cash.Value += 1000000000
end
end
-- Gives the user 100b
productFunctions[1650731748] = function(receipt, player)
-- make it that when it is run it would give player 100000000
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
if cash then
cash.Value += 100000000000
end
end
-- Gives the user 1T
productFunctions[1650733652] = function(receipt, player)
-- make it that when it is run it would give player 100000000
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
if cash then
cash.Value += 1000000000000
end
end
local function processReceipt(receiptInfo)
local userId = receiptInfo.PlayerId
local productId = receiptInfo.ProductId
local player = Players:GetPlayerByUserId(userId)
if player then
-- Get the handler function associated with the developer product ID and attempt to run it
local handler = productFunctions[productId]
local success, result = pcall(handler, receiptInfo, player)
if success then
-- The user has received their benefits!
-- return PurchaseGranted to confirm the transaction.
return Enum.ProductPurchaseDecision.PurchaseGranted
else
warn("Failed to process receipt:", receiptInfo, result)
end
end
end
Marketplaceservice.ProcessReceipt = processReceipt
If you make the script match all the other functions you had (with it going receipt, player) instead of just player, it should function again:
i.e.
local devproIDGod = 1650733652
local devproIDsuper = 1650731748
local devproIDultra = 1650730956
local devproIDpro = 1650730083
local devproIDnoob = 1650729210
local Marketplaceservice = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productFunctions = {}
-- Gives the user 100,000 cash
productFunctions[1650729210] = function(receipt, player)
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
if cash then
cash.Value += 100000
end
end
-- Gives the user 100,000,000
productFunctions[1650730083] = function(receipt, player)
-- make it that when it is run it would give player 100000000
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
if cash then
cash.Value += 100000000
end
end
-- Gives the user 1b
productFunctions[1650730956] = function(receipt, player)
-- make it that when it is run it would give player 100000000
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
if cash then
cash.Value += 1000000000
end
end
-- Gives the user 100b
productFunctions[1650731748] = function(receipt, player)
-- make it that when it is run it would give player 100000000
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
if cash then
cash.Value += 100000000000
end
end
-- Gives the user 1T
productFunctions[1650733652] = function(receipt, player)
-- make it that when it is run it would give player 100000000
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
if cash then
cash.Value += 1000000000000
end
end
local function processReceipt(receiptInfo)
local userId = receiptInfo.PlayerId
local productId = receiptInfo.ProductId
local player = Players:GetPlayerByUserId(userId)
if player then
-- Get the handler function associated with the developer product ID and attempt to run it
local handler = productFunctions[productId]
local success, result = pcall(handler, receiptInfo, player)
if success then
-- The user has received their benefits!
-- return PurchaseGranted to confirm the transaction.
return Enum.ProductPurchaseDecision.PurchaseGranted
else
warn("Failed to process receipt:", receiptInfo, result)
end
end
end
Marketplaceservice.ProcessReceipt = processReceipt