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 script that is located in ServerScriptStorage not giving my character a tool?

Asked by 11 months ago

When I purchase a developer product in my game it gives me the receipt and everything however it doesn't give me the popcorn/product. What is wrong with my script?

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

1 answer

Log in to vote
0
Answered by
memguy 121
11 months ago

:GetChildren() returns an array of all children of an object. Basically, the player variable was not the player but all of them.

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 = players[i]
    cloned.Parent = player.Backpack
    cloned.Parent = player.StarterGear
print("cool")
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted 
end
0
unfortunately it still does not work Zeppelin0330 23 — 11mo
Ad

Answer this question