[MarketplaceService] Argument 1 missing or nil help

Hello!
I am creating very simple script to check if a player owns a tshirt, if they do then fire a RemoteEvent and if they do not then prompt the purchase of the tshirt and if the outcome is that the player bought it, then the same RemoteEvent will be fired.

LocalScript inside a text button:

local MPS = game:GetService("MarketplaceService")
local ID = 1234 --removed actual id for now
local ts = game:GetService("TweenService")

script.Parent.MouseButton1Click:Connect(function(player)
	if MPS:PlayerOwnsAsset(player, ID) then --error occurs here!!!
		game.ReplicatedStorage.ShirtEvent:FireServer(game.Players.LocalPlayer)
	else
		MPS:PromptPurchase(player, ID)

		MPS.PromptPurchaseFinished:Connect(function(player, ID, isPurchased)
			if isPurchased == Enum.ProductPurchaseDecision.PurchaseGranted then
				game.ReplicatedStorage.ShirtEvent:FireServer(game.Players.LocalPlayer)
			elseif isPurchased == Enum.ProductPurchaseDecision.NotProcessedYet then
                  --placeholder for now
			else
				print("invalid")
			end
		end)
	end
	
end)```

Player doesn’t get passed from a mouse click event. If it’s in a local script which it should be then you can just instead of Player do game.Players.LocalPlayer

If I add a variable at the top such as the one below, would it work?

local player = game.Players.LocalPlayer
1 Like

That would work fine as well. As you are using it more than once it is probably best

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.