Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.