- within my code, i have the following lines on the end of a major script:
[SCRIPT]
playerEvents.Purchase.OnServerEvent:Connect(function(player, productId, productName)
if configurationsModule["Shop"][productName]["GamepassId"]~=nil then
marketplaceService:PromptGamePassPurchase(player, configurationsModule["Shop"][productName]["GamepassId"])
else
marketplaceService:PromptProductPurchase(player, productId)
end
end)
-- this small section decides does it give gamepass purchase or a product purchase based on does it find gamepassId within a configurationsModule
local function processReceipt(receiptInfo)
print("PURCHASE")
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
local productId = receiptInfo.ProductId
local productName = marketplaceService:GetProductInfo(productId, Enum.InfoType.Product).Name
print(player.Name.." bought "..productName.."("..productId..")")
-- some further logic
end
local function processGamepass(player, gamepassId, hasPurchased)
local productName = configurationsModule["GamepassIds"][tostring(gamepassId)]
print(player.Name.." bought "..productName.."("..gamepassId..")")
player.Gamepasses:FindFirstChild("Gamepass_"..productName).Value=1
end
marketplaceService.ProcessReceipt = processReceipt
marketplaceService.PromptGamePassPurchaseFinished:Connect(processGamepass)
[SCRIPT]
-
i will note, all of this is not within any kind of loop, and is not in a script that can duplicate and play multiple times, however there is an issue where when i buy something once everything is good, but when i buy it again then the logics play out twice, next time its 3, then 4 etc.
-
i have just added (some further logic) as that is not the important part, it has no loops and plays out only once.
-
this is what output had (without some other printing that is unrelated):
-
first purchase:
PURCHASE - Server - CoreScript:639
borotoni73 bought placeholder_name(3610664069) - Server - CoreScript:644 -
second purchase:
PURCHASE (x2) - Server - CoreScript:639
borotoni73 bought placeholder_name(3610664069) (2) - Server - CoreScript:644 -
does anyone know how can fix this issue, as when i went to check i was buying too fast and i waited like 5 minutes between the purchases it still played out the logics and prints twice