Hi devs. I have a little problem with my Marketplace. If per example i buy 200 xp, i'll get receive them normally, but as soon as i try to buy another thing all previous item execute again, why and how?
I dont know if you guys understand what I mean
If I buy xp/money
First purchase output:
439092562
Now if I buy money/xp
Secondly purchase output:
439092562 (x2)
439094412
I recieve xp and money id, why and how?
LocalScript Explorer
--< Services local PlayerService = game:GetService('Players') local MarketplaceService = game:GetService('MarketplaceService') --< Events for _, SurfaceGui in pairs(script.Parent:GetChildren()) do if SurfaceGui:IsA('SurfaceGui') then for _, ImageLabel in pairs(SurfaceGui.Shop:GetChildren()) do ImageLabel.Button.MouseButton1Click:Connect(function() MarketplaceService:PromptProductPurchase(PlayerService.LocalPlayer, ImageLabel.Name) end) end end end
Script
local PlayerService = game:GetService('Players') MarketplaceService.ProcessReceipt = function(ReveipInfo) local Player = PlayerService:GetPlayerByUserId(ReveipInfo.PlayerId) local ProductId = ReveipInfo.ProductId if ProductId == 439094412 then -- +325 money DataManager:ChangeStat(Player, 350, 'Money', true) print(ReveipInfo.ProductId) elseif ProductId == 439103355 then -- +550 money DataManager:ChangeStat(Player, 550, 'Money', true) print(ReveipInfo.ProductId) elseif ProductId == 439103573 then -- +875 money DataManager:ChangeStat(Player, 875, 'Money', true) print(ReveipInfo.ProductId) elseif ProductId == 439104104 then -- +1,200 money DataManager:ChangeStat(Player, 1200, 'Money', true) print(ReveipInfo.ProductId) elseif ProductId == 439092562 then -- +200 exp DataManager:ChangeStat(Player, 200, 'Experience', true) print(ReveipInfo.ProductId) elseif ProductId == 439092841 then -- +400 exp DataManager:ChangeStat(Player, 400, 'Experience', true) print(ReveipInfo.ProductId) elseif ProductId == 439093127 then -- +800 exp DataManager:ChangeStat(Player, 800, 'Experience', true) print(ReveipInfo.ProductId) elseif ProductId == 439094114 then -- +1,600 exp DataManager:ChangeStat(Player, 1600, 'Experience', true) print(ReveipInfo.ProductId) end end
This is because you are not returning PurchaseGranted unpon successfully processing the players purchase.
This is used to make sure that the developer can decline the sale for what ever reason. This sale would then call the PurchaseGranted event until PurchaseGranted is returned.
Example
local success, fail = Enum.ProductPurchaseDecision.PurchaseGranted, Enum.ProductPurchaseDecision.NotProcessedYet MarketplaceService.ProcessReceipt = function(ReveipInfo) local sale = fail -- def should be fail if ReveipInfo.ProductId == 439094412 then -- code sale = success -- sets this sale as successfully processed end return sale end
Hope this helps.