Help with Developer Product

when a player buys a developer product I want it will print in the server message
for some reason my script don’t work i will appreciate if someone help me

server script:

local MarketplaceService = game:GetService("MarketplaceService")
local prodId

local robux_10 = 1319870523
local robux_50 = 1319870592
local robux_100 = 1319870692
local robux_500 = 1319870771
local robux_1000 = 1319870853
local robux_5000 = 1319871002

MarketplaceService.ProcessReceipt = function(receiptInfo)
	
	local Player = game.Players:GetChildren()
	
	for i = 1, #Player do
		if Player[i].userId == receiptInfo.PlayerId then
			
			prodId = receiptInfo.ProductId
			
			if prodId == robux_10 then
				print("thanks for 10 robux")
			elseif prodId == robux_50 then
				
			elseif prodId == robux_100 then
				
			elseif prodId == robux_500 then
				
			elseif prodId == robux_1000 then
				
			elseif prodId == robux_5000 then

			else
				print("Something went wrong.") 
			end
			print("thanks")
		end
	end
	
end

local script:

local marketplaceServie = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function()

marketplaceServie:PromptProductPurchase(game.Players.LocalPlayer,1319870853)

end).
1 Like

You are doing: if Player[i].userId == receiptInfo.PlayerId then but you need to capitalize the U in UserId. It’ll look like this:

if Player[i].UserId == receiptInfo.PlayerId then

I also recommend changing your approach to use the function :GetPlayerByUserId() You can see the documentation here:

https://create.roblox.com/docs/reference/engine/classes/Players#GetPlayerByUserId

If you have any questions let me know!

1 Like