New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Why is my prompt purchase not giving the player the product?

Asked by 3 months ago
Edited 3 months ago

The prompt purchase appears correctly however when the transaction is completed the product does not appear in their inventory. This script is located in ServerScriptService and the tool is located in Replicated Storage. When I run it gives me no error but still wont put the popcorn in to the players backpack. Any help is appreciated.

local MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
local players = game.Players:GetPlayers()
for i=1,#players do
if players[i].UserId == receiptInfo.PlayerId then
    local RS = game:GetService("ReplicatedStorage")
    local item = RS:WaitForChild("Popcorn")
    local cloned = item:Clone()
    local player = game.Players:GetChildren()
    cloned.Parent = player.Backpack
    cloned.Parent = player.StarterGear
print("cool")
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted 
end
0
the server cant access players, only a local script can but what i think you can do is local players = game.Players:GetChildren() but im not sure Gameplayer365247v2 729 — 3mo
0
and btw userId is not a valid member of a player, instead use UserId Gameplayer365247v2 729 — 3mo
0
ok ill try thank u Zeppelin0330 9 — 3mo
0
the popcorn itself is not going into the inventory now though Zeppelin0330 9 — 3mo

Answer this question