Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

A little help?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I have no idea what's wrong with this script... can anyone find the problem?

game:GetService("MarketplaceService"):PromptProductPurchase(game.Workspace.player, 20509650)
local devId = 20509650 --Put the dev product ID here
local sword = game:GetService("ServerStorage"):FindFirstChild("Sword") --Put the path to the sword here

game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
    for i,v in ipairs (game.Players:GetChildren()) do
        if v.userId == receiptInfo.PlayerId then --If the player matches the player in the receipt
            if receiptInfo.ProductId == devId then --If it's the correct developer product
                if pcall(function()
                sword:Clone().Parent = v.StarterGear
                sword:Clone().Parent = v.Backpack
                end) then return Enum.ProductPurchaseDecision.PurchaseGranted end --Tells the marketplace service that purchase went smoothly.
            end
        end
    end
end

1 answer

Log in to vote
0
Answered by 10 years ago

player is not a valid member of Workspace

Ad

Answer this question