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

I don't understand why my Marketplace Service script doesn't work?

Asked by 3 years ago

So earlier I asked a question about how to make purchases that can be bought over and over, but I tried to make the script activate by being clicked but it doesn't work... Output says " 19:20:21.067 - MarketplaceService:PromptProductPurchase() player should be of type Player, but is of type nil"

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local productID = 1012008207  -- Change this to your developer product ID
local productInfo = MarketplaceService:GetProductInfo(productID, Enum.InfoType.Product)

-- Function to prompt purchase of the developer product
local function promptPurchase()
    local player = Players.LocalPlayer
    MarketplaceService:PromptProductPurchase(player, productID)
end

script.Parent.ClickDetector.MouseClick:Connect(promptPurchase)

1 answer

Log in to vote
0
Answered by
3F1VE 257 Moderation Voter
3 years ago

You can use the :GetPlayerFromCharacter() function. More info about it here

Ad

Answer this question