-- -- Written by @DevKeia on 8/1/23 --
-- As most customizable allowed scripts, we do have certain comments in here! --
local MarketplaceService = game:GetService("MarketplaceService") -- Marketplace --
local DatastoreService = game:GetService("DataStoreService") -- Service for DS --
local PreviousPurchases = DatastoreService:GetDataStore("PreviousPurchases") -- creates the datastore --
local productFunctions = {} -- this table will contain all of product ids and functions
local ONE_HUNDRED_CASH = 1597416227 -- 100 cash id --
local FOUR_HUNDRED_FIFTY_CASH = 1597417372 -- 450 cash id --
local ONE_THOUSAND_CASH = 1597417917 -- 1000 cash id --
local TEN_THOUSAND_CASH = 1597418310 -- 10000 cash id --
local function giveCash(plr, amt) -- this function will simply give the player cash
plr.leaderstats.Cash.Value += amt
end
productFunctions[ONE_HUNDRED_CASH] = function(info, plr) -- gives plr 100 cash
giveCash(plr, 100)
end
productFunctions[FOUR_HUNDRED_FIFTY_CASH] = function(info, plr) -- gives plr 450 cash
giveCash(plr, 450)
end
productFunctions[ONE_THOUSAND_CASH] = function(info, plr) -- gives plr 1000 cash
giveCash(plr, 1000)
end
productFunctions[TEN_THOUSAND_CASH] = function(info, plr) -- gives plr 10000 cash
giveCash(plr, 10000)
end
-- when a devproduct is bought in game, it will look through this function. --
MarketplaceService.ProcessReceipt = function(reciept)
local ID = reciept.PlayerId.."-"..reciept.PurchaseId -- not relevant but did you mean to put ProductId here instead of PurchaseId?
if PreviousPurchases:GetAsync(ID) then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local player = game.Players:GetPlayerByUserId(reciept.PlayerId)
if not player then return Enum.ProductPurchaseDecision.NotProcessedYet end
local handler = productFunctions[reciept.ProductId]
local s, e = pcall(function(handler, reciept, player)
if s then return Enum.ProductPurchaseDesicion.PurchaseGranted else warn(e) return Enum.ProductPurchaseDecision.NotProcessedYet end
end
I get no errors, and it still doesn’t work, the purchase goes through, and also FYI: The value is coin and it is not in leaderstats it is a folder called mainData which the value is called “Coins”. Again, please help. I really need to get this game out
-- -- Written by @DevKeia on 8/1/23 --
-- As most customizable allowed scripts, we do have certain comments in here! --
local MarketplaceService = game:GetService("MarketplaceService") -- Marketplace --
local DatastoreService = game:GetService("DataStoreService") -- Service for DS --
local PreviousPurchases = DatastoreService:GetDataStore("PreviousPurchases") -- creates the datastore --
local productFunctions = {} -- this table will contain all of product ids and functions
local ONE_HUNDRED_CASH = 1597416227 -- 100 cash id --
local FOUR_HUNDRED_FIFTY_CASH = 1597417372 -- 450 cash id --
local ONE_THOUSAND_CASH = 1597417917 -- 1000 cash id --
local TEN_THOUSAND_CASH = 1597418310 -- 10000 cash id --
local function giveCash(plr, amt) -- this function will simply give the player cash
plr.mainData.Cash.Value += amt
end
productFunctions[ONE_HUNDRED_CASH] = function(info, plr) -- gives plr 100 cash
giveCash(plr, 100)
end
productFunctions[FOUR_HUNDRED_FIFTY_CASH] = function(info, plr) -- gives plr 450 cash
giveCash(plr, 450)
end
productFunctions[ONE_THOUSAND_CASH] = function(info, plr) -- gives plr 1000 cash
giveCash(plr, 1000)
end
productFunctions[TEN_THOUSAND_CASH] = function(info, plr) -- gives plr 10000 cash
giveCash(plr, 10000)
end
-- when a devproduct is bought in game, it will look through this function. --
local function procRec(reciept)
local ID = reciept.PlayerId.."-"..reciept.PurchaseId -- not relevant but did you mean to put ProductId here instead of PurchaseId?
if PreviousPurchases:GetAsync(ID) then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local player = game.Players:GetPlayerByUserId(reciept.PlayerId)
if not player then return Enum.ProductPurchaseDecision.NotProcessedYet end
print(1)
local handler = productFunctions[reciept.ProductId]
print(2)
local s, e = pcall(function(handler, reciept, player)
print(3)
if s then return Enum.ProductPurchaseDesicion.PurchaseGranted prin("supposedly went through") else warn(e) return Enum.ProductPurchaseDecision.NotProcessedYet end
end
MarketplaceService.ProcessReceipt = procRec
if s then print("supposedly went through") return Enum.ProductPurchaseDesicion.PurchaseGranted elseif not s then warn(e) return Enum.ProductPurchaseDecision.NotProcessedYet end
oh wait i see whats going on
where it says local s,e = pcall(function... you want to remove function and that open parenthesisto the right of it (you still want to use the previous line of code too though)
-- -- Written by @DevKeia on 8/1/23 --
-- As most customizable allowed scripts, we do have certain comments in here! --
local MarketplaceService = game:GetService("MarketplaceService") -- Marketplace --
local DatastoreService = game:GetService("DataStoreService") -- Service for DS --
local PreviousPurchases = DatastoreService:GetDataStore("PreviousPurchases") -- creates the datastore --
local productFunctions = {} -- this table will contain all of product ids and functions
local ONE_HUNDRED_CASH = 1597416227 -- 100 cash id --
local FOUR_HUNDRED_FIFTY_CASH = 1597417372 -- 450 cash id --
local ONE_THOUSAND_CASH = 1597417917 -- 1000 cash id --
local TEN_THOUSAND_CASH = 1597418310 -- 10000 cash id --
local function giveCash(plr, amt) -- this function will simply give the player cash
wait(1)
plr.mainData.Cash.Value += amt
end
productFunctions[ONE_HUNDRED_CASH] = function(info, plr) -- gives plr 100 cash
giveCash(plr, 100)
end
productFunctions[FOUR_HUNDRED_FIFTY_CASH] = function(info, plr) -- gives plr 450 cash
giveCash(plr, 450)
end
productFunctions[ONE_THOUSAND_CASH] = function(info, plr) -- gives plr 1000 cash
giveCash(plr, 1000)
end
productFunctions[TEN_THOUSAND_CASH] = function(info, plr) -- gives plr 10000 cash
giveCash(plr, 10000)
end
-- when a devproduct is bought in game, it will look through this function. --
local function procRec(reciept)
local ID = reciept.PlayerId.."-"..reciept.PurchaseId -- not relevant but did you mean to put ProductId here instead of PurchaseId?
if PreviousPurchases:GetAsync(ID) then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local player = game.Players:GetPlayerByUserId(reciept.PlayerId)
if not player then return Enum.ProductPurchaseDecision.NotProcessedYet end
print(1)
local handler = productFunctions[reciept.ProductId]
print(2)
local s, e = pcall(function(handler, reciept, player)
print(3)
local s, e = pcall(handler, reciept, player)
if s then print("supposedly went through") return Enum.ProductPurchaseDesicion.PurchaseGranted elseif not s then warn(e) return Enum.ProductPurchaseDecision.NotProcessedYet end
end)
end
MarketplaceService.ProcessReceipt = procRec
-- -- Written by @DevKeia on 8/1/23 --
-- As most customizable allowed scripts, we do have certain comments in here! --
local MarketplaceService = game:GetService("MarketplaceService") -- Marketplace --
local DatastoreService = game:GetService("DataStoreService") -- Service for DS --
local PreviousPurchases = DatastoreService:GetDataStore("PreviousPurchases") -- creates the datastore --
local productFunctions = {} -- this table will contain all of product ids and functions
local ONE_HUNDRED_CASH = 1597416227 -- 100 cash id --
local FOUR_HUNDRED_FIFTY_CASH = 1597417372 -- 450 cash id --
local ONE_THOUSAND_CASH = 1597417917 -- 1000 cash id --
local TEN_THOUSAND_CASH = 1597418310 -- 10000 cash id --
local function giveCash(plr, amt) -- this function will simply give the player cash
wait(1)
plr.mainData.Cash.Value += amt
end
productFunctions[ONE_HUNDRED_CASH] = function(info, plr) -- gives plr 100 cash
giveCash(plr, 100)
end
productFunctions[FOUR_HUNDRED_FIFTY_CASH] = function(info, plr) -- gives plr 450 cash
giveCash(plr, 450)
end
productFunctions[ONE_THOUSAND_CASH] = function(info, plr) -- gives plr 1000 cash
giveCash(plr, 1000)
end
productFunctions[TEN_THOUSAND_CASH] = function(info, plr) -- gives plr 10000 cash
giveCash(plr, 10000)
end
-- when a devproduct is bought in game, it will look through this function. --
local function procRec(reciept)
local ID = reciept.PlayerId.."-"..reciept.PurchaseId -- not relevant but did you mean to put ProductId here instead of PurchaseId?
if PreviousPurchases:GetAsync(ID) then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local player = game.Players:GetPlayerByUserId(reciept.PlayerId)
if not player then return Enum.ProductPurchaseDecision.NotProcessedYet end
print(1)
local handler = productFunctions[reciept.ProductId]
print(2)
local s, e = pcall(function()
handler(reciept, player)
end)
if s then print("supposedly went through") return Enum.ProductPurchaseDesicion.PurchaseGranted elseif not s then warn(e) return Enum.ProductPurchaseDecision.NotProcessedYet end
end
MarketplaceService.ProcessReceipt = procRec