I am currently using this event to detect whenever a dev product has been purchased, is this bad to use, if so why? I am using it to allow players to gift gems and coins to their friends
MarketPlaceService.PromptProductPurchaseFinished:Connect(function(userId, productId, isPurchased)
end)
Server-side Module script:
promptPurchaseEvent.OnServerEvent:Connect(function(player, id, giftToPlayer)
prodModule.buyProducts(player, id, giftToPlayer)
end)
function module.buyProducts(Player, ProductId, PlayerToGift)
if not ProductPurchasedCD[Player] then
ProductPurchasedCD[Player] = true
MarketPlaceService:PromptProductPurchase(Player, ProductId)
giftTable[Player.UserId] = Player
if PlayerToGift and game.Players:FindFirstChild(PlayerToGift) then giftTable[Player.UserId] = PlayerToGift end
if PlayerToGift and game.Players:FindFirstChild(PlayerToGift) then
game.ReplicatedStorage.Events.SuccessEvent:FireClient(Player, "Notify", {Color = Color3.fromRGB(255,255,255), Text = "Gifted To: ", NewItem = false, MultiColor = false, Coloured = true, StartColoured = '<font color= "rgb(48, 255, 132)">', End = "</font>", ColouredText = tostring(game.Players:FindFirstChild(PlayerToGift)), CustomSound = 2650044156})
end
task.wait(1)
ProductPurchasedCD[Player] = false
end
end
MarketPlaceService.PromptProductPurchaseFinished:Connect(function(userId, productId, isPurchased)
print("purchased")
if isPurchased and giftTable[userId] then
module.GiveProducts(giftTable[userId], productId)
if giftTable[userId] and game.Players:GetPlayerByUserId(userId) ~= giftTable[userId] then
game.ReplicatedStorage.Events.SuccessEvent:FireClient(giftTable[userId], "Notify", {Color = Color3.fromRGB(255,255,255), Text = "You've been gifted by ", NewItem = false, MultiColor = false, Coloured = true, StartColoured = '<font color= "rgb(48, 255, 132)">', End = "</font>", ColouredText = tostring(game.Players:GetPlayerByUserId(userId)), CustomSound = 2650044156})
end
if giftTable[userId] and game.Players:GetPlayerByUserId(userId) == giftTable[userId] then
game.ReplicatedStorage.Events.SuccessEvent:FireClient(giftTable[userId], "Notify", {Color = Color3.fromRGB(255,255,255), Text = "Successful Purchase", NewItem = false, MultiColor = false, Coloured = false, StartColoured = '<font color= "rgb(48, 255, 132)">', End = "</font>", ColouredText = nil, CustomSound = 2650044156})
end
end
end)
