I have set up multiple dev products into one script (recently found out thats bad?)
And i tried searching for a solution but i have found no help
My issue is that i have implemented a skip button in my game to get to the next level by paying but the thing is they can press buy and then when prompt comes up they can just press cancel and the game will somehow allow that and change the value of where they respawn even though its not supposed to be like that
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local event = game.ReplicatedStorage.BuyHandle
local ProfileCache = require(game.ServerScriptService.ProfileCacher)
local productID = codes
local productIDf = codes
local productIDot = codes
local productIDtt = codes
local productIDft = codes
local productIDur = codes
local productIDbp = codes
local shirtID = codes
local skipID = codes
local canQID = codes
local showPrompt = true
-- Function to prompt purchase of the developer product
local function promptPurchase(player, data)
local claimed = player.stat.Claimed
if data == 5 then
MarketplaceService:PromptProductPurchase(player, productIDbp)
end
if data == 100 then
MarketplaceService:PromptProductPurchase(player, productID)
end
if data == 500 then
MarketplaceService:PromptProductPurchase(player, productIDf)
end
if data == 1000 then
MarketplaceService:PromptProductPurchase(player, productIDot)
end
if data == 2500 then
MarketplaceService:PromptProductPurchase(player, productIDtt)
end
if data == 5000 then
MarketplaceService:PromptProductPurchase(player, productIDft)
end
if data == 8888 then
MarketplaceService:PromptProductPurchase(player, productIDur)
end
if data == shirtID then
MarketplaceService:PromptPurchase(player, shirtID)
end
if data == skipID then
MarketplaceService:PromptProductPurchase(player, skipID)
end
if data == canQID then
MarketplaceService:PromptProductPurchase(player, canQID)
end
--Premium
if data == 555 then
if not player then return end
if claimed.Value == 0 then
if player.MembershipType == Enum.MembershipType.Premium then
local playerProfile = ProfileCache[player]
playerProfile.Data.Cash += 10000
if player.leaderstats.Level.Value < 8 then
playerProfile.Data.XP = 15900
end
if player.stat.Axe.Value < 8 then
playerProfile.Data.Axe = 8
end
playerProfile.Data.Claimed = 1
-- Else, prompt Premium upgrade (use debounce to show it only once every few seconds)
else
if showPrompt == false then return end
showPrompt = false
delay(5, function()
showPrompt = true
end)
MarketplaceService:PromptPremiumPurchase(player)
warn("Prompted Premium purchase")
end
end
end
end
MarketplaceService.PromptPremiumPurchaseFinished:Connect(function(player)
warn("Premium modal closed")
end)
event.OnServerEvent:Connect(function(player, data)
promptPurchase(player, data)
end)
local function processReceipt(receiptInfo)
local plr = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not plr then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == productID then
if plr then
local playerProfile = ProfileCache[plr]
playerProfile.Data.Cash += 10000
end
end
if receiptInfo.ProductId == productIDf then
if plr then
local playerProfile = ProfileCache[plr]
playerProfile.Data.Cash += 25000
end
end
if receiptInfo.ProductId == productIDot then
if plr then
local playerProfile = ProfileCache[plr]
playerProfile.Data.Cash += 75000
end
end
if receiptInfo.ProductId == productIDtt then
if plr then
local playerProfile = ProfileCache[plr]
playerProfile.Data.Cash += 150000
end
end
if receiptInfo.ProductId == productIDft then
if plr then
local playerProfile = ProfileCache[plr]
playerProfile.Data.Cash += 300000
end
end
if receiptInfo.ProductId == productIDur then
if plr then
local playerProfile = ProfileCache[plr]
playerProfile.Data.unlimitedrep = 1
playerProfile.Data.REP = 100
end
end
if receiptInfo.ProductId == productIDbp then
if plr then
local playerProfile = ProfileCache[plr]
playerProfile.Data.petfive = 1
end
end
if receiptInfo.ProductId == skipID then
if plr then
local playerProfile = ProfileCache[plr]
local ccp = plr.stat.currentcp
local lcp = plr.stat.lastcp
local skiploc = lcp.Value + 1
local cp = {workspace.obbyspawn, workspace.Checkpoint1.spawn, workspace.Checkpoint2.spawn, workspace.Checkpoint3.spawn, workspace.Checkpoint4.spawn, workspace.Checkpoint5.spawn, workspace.Checkpoint6.spawn, workspace.Checkpoint7.spawn, workspace.Checkpoint8.spawn, workspace.Checkpoint9.spawn, workspace.Checkpoint10.spawn, workspace.Checkpoint11.spawn, workspace.Checkpoint12.spawn, workspace.Checkpoint13.spawn, workspace.Checkpoint14.spawn}
plr.Character.HumanoidRootPart.CFrame = CFrame.new(cp[skiploc].Position)
end
end
if receiptInfo.ProductId == canQID then
if plr then
local playerProfile = ProfileCache[plr]
playerProfile.Data.currentpet = 0
playerProfile.Data.canequip = 1
plr.Character.Humanoid.Health -= 200
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
help would be great… as right now the game is breaking hard. to the point where checkpoints dont work how they are supposed to work as well.