Hello, I'm making a obby type game with a shop gui where you can buy products to skip either one, five or ten stages. The problem is the script to skip one stage works but it doesn't work to skip 5 stages. My local scripts to prompt the purchase to the player work but for some reason when I try to add more than one stage to the player leaderstats value it doesn't work. I would be so thankful if y'all can help me. (code below
Here's the server side script to skip one stage product (working) :
local marketPlaceService = game:GetService("MarketplaceService") marketPlaceService.ProcessReceipt = function(receiptInfo) local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) if receiptInfo.ProductId == 1337983530 then player.leaderstats:FindFirstChild("???? Stage").Value += 1 wait(1) player:LoadCharacter() return Enum.ProductPurchaseDecision.PurchaseGranted end end
And here is the server side script for the skip five stages product (not working) :
local marketPlaceService = game:GetService("MarketplaceService") marketPlaceService.ProcessReceipt = function(receiptInfo) local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) if receiptInfo.ProductId == 1339759965 then player.leaderstats:FindFirstChild("???? Stage").Value += 5 wait(1) player:LoadCharacter() return Enum.ProductPurchaseDecision.PurchaseGranted end end
Thanks in advance, ASE.
You can only set ProcessReceipt once. So just combine it into one script.
local marketPlaceService = game:GetService("MarketplaceService") marketPlaceService.ProcessReceipt = function(receiptInfo) local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) local function addStage(amount) player.leaderstats:FindFirstChild("???? Stage").Value += amount wait(1) player:LoadCharacter() end if receiptInfo.ProductId == 1337983530 then addStage(1) return Enum.ProductPurchaseDecision.PurchaseGranted elseif receiptInfo.ProductId == 1339759965 then addStage(5) return Enum.ProductPurchaseDecision.PurchaseGranted end end