local MS = game:GetService("MarketplaceService")
local PickNextEffect = 1122472327
local players = game:GetService("Players")
local Effect = function(plr, effect)
game.ServerStorage.NextEffect.Value = effect
end
local function processReceipt(info)
local plr = players:GetPlayerByUserId(info.PlayerId)
if not plr then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if plr then
if info.ProductId == PickNextEffect then
game.ReplicatedStorage.Events.MultiPurpouse:FireClient(plr, "ChooseEffect")
--the event below i what i need help with
game.ReplicatedStorage.Events.Effect.OnServerEvent:Wait(function(plr, effect)
game.ServerStorage.NextEffect.Value = effect
print("hi")
end)
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MS.ProcessReceipt = processReceipt
What you’re trying to do is definitely not the best solution, but for your question, :Wait() returns the arguments given to it. You would just have to do
local player,effect = game.ReplicatedStorage.Events.Effect.OnServerEvent:Wait()
For one, you are waiting for the player to reply to complete the purchase (you shouldn’t trust the client to do something). Moreover, any player can fire to that event and trigger it, meaning that some random player could fire that event while a player is purchasing that product.
The first issue is basically unavoidable because they have to pick from a selection of effects.
But the second issue is a problem, Maybe if I compare the name of the player sending the event to the one from the purchase?
The best solution would be to have a developer product for every effect and let the player choose which one prior to purchasing the effect so you don’t have to rely on the player’s response. However, to answer the question, comparing names could work, but the solution would look pretty hacky. Either have a while loop that keeps :Wait()ing the event until the player responds, or :Connect() and have a while loop that yields until the player responds.