Please help! (This is a server script)
script.Parent.MouseButton1Click:connect(function(player) game:GetService("MarketplaceService"):PromptPurchase(player, 2286611813) end)
Error: MarketPlaceService:PromptPurchase() player should be of type, but type is nil
Question: Prompt Purchase does not prompt.
The reason why is because there's no parameters with MouseButton1Click
. That's why player
is returning nil, since it doesn't exist.
You'll have to use another method of grabbing the player, such as RemoteEvents.
ALSO: connect
is deprecated. Please use Connect
instead.
LocalScript
, use LocalPlayer
, and problem solved. Always remember to use Local Scripts when working with GUIs.local player = game.Players.LocalPlayer -- this only works in localscripts script.Parent.MouseButton1Click:Connect(function() game:GetService("MarketplaceService"):PromptPurchase(player, 2286611813) -- if you want to prompt a game pass, use :PromptGamePassPurchase end)