Why is my dev product not working?

Hi, I’m making a coin devproduct and It is not giving me the coins
local script:

local id = 1158532333
local MPS = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	MPS:PromptProductPurchase(player, id)
	MPS.PromptPurchaseFinished:Connect(function(player, id, isPurchased)
		if isPurchased then
			print(player.Name .. " bought an item with AssetID: " .. id)
			game.ReplicatedStorage.GroupCoinEvent:FireServer(player)
		else
			print(player.Name .. " didn't buy an item with AssetID: " .. id)
		end
	end)
end)

server script:

game.ReplicatedStorage.Events.GroupCoinEvent.OnServerEvent:Connect(function(player)
	player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + math.random(500,1000)
end)

It may be because you are connecting the event tool late. Though you should also test if the function that you have connected is even firing

It’s not printing player has bought an item with asset id.

You forgot Events in your local script if you add it to the line it could be fixed.

You don’t need to pass anything through the FireServer event, it’s just tuple arguments also:

Handle this on the server instead please

like this? (it doesn’t work)
localscript

local id = 1158532333
local MPS = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	MPS:PromptProductPurchase(player, id)
	game.ReplicatedStorage.Events.GroupCoinEvent:FireServer()
end)

serverscript:

local MPS = game:GetService("MarketplaceService")
local id = 1158532333
game.ReplicatedStorage.Events.GroupCoinEvent.OnServerEvent:Connect(function(player)
	MPS.PromptPurchaseFinished:Connect(function(player, id, isPurchased)
		if isPurchased then
			print(player.Name .. " bought an item with AssetID: " .. id)
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + math.random(500,1000)
		else
			print(player.Name .. " didn't buy an item with AssetID: " .. id)
		end
		end)
end)

I’m not the best at dev products but try this:

Client:

local id = 1158532333
local MPS = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	MPS:PromptProductPurchase(player, id)
end)

Server:

local id = 1158532333
local MPS = game:GetService("MarketplaceService")

MPS.PromptPurchaseFinished:Connect(function(player, productid, isPurchased)
		if isPurchased and productid == id then
			print(player.Name .. " bought an item with AssetID: " .. id)
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + math.random(500,1000)
		else
			print(player.Name .. " didn't buy an item with AssetID: " .. id)
		end
	end)

Still not working for me. :frowning:

You need to set the callback of .ProcessReceipt and give the money in there. Then return ProductPurchaseDecision | Documentation - Roblox Creator Hub .PurchaseGranted

1 Like