Defining specific player in serverscript

I’m trying to make a purchaseprompt show up when a player clicks a part.
It is for a donation button so it should only show up for the player that clicked the part but I can’t find a way to define which player.

local Id = 1230382574
local clickDetector = workspace.Part.ClickDetector
local MarketPlaceService = game:GetService("MarketplaceService")

function onMouseClick()
	game:GetService("MarketplaceService"):PromptProductPurchase(Player,Id)
	print("Prompt Succesfull")
end

clickDetector.MouseClick:connect(onMouseClick)

I get this error. “MarketplaceService:PromptProductPurchase() player should be of type Player - Server - Script:6”
Thanks.

MouseClick event has player as first parameter, you don’t need to do much.

local Id = 1230382574
local clickDetector = workspace.Part.ClickDetector
local MarketPlaceService = game:GetService("MarketplaceService")

local function onMouseClick(Player)
	game:GetService("MarketplaceService"):PromptProductPurchase(Player, Id)
	print("Prompt Succesfull")
end

clickDetector.MouseClick:Connect(onMouseClick)
2 Likes

Thanks a lot,
Works perfectly now.