Hello,
I am trying to make a gui that when you click prompts a purchase to buy a shirt. When I click it gives me an error saying “[MarketplaceService:PromptPurchase() player should be of type Player, but is of type nil”. Here is the code:
local itemID = 5668245964
script.Parent.MouseButton1Click:Connect(function(p)
game:GetService("MarketplaceService"):PromptPurchase(p,itemID)
end)
Define the player by using local player = game.Players.LocalPlayer and then say:
local itemID = 5668245964
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
game:GetService("MarketplaceService"):PromptPurchase(player,itemID)
end)
Ok first make sure that your gamepass id is valid. If it is a gamepass, I recommend using PromptGamePassPurchase. Also this only works if it is a local script.