How CAN I solve this Currency Developer Product error?

Hello everyone
So yesterday I made a shop of Developer Products. Those Developer Products give you certain currency when you buy it(it depend of the Developer Product you are buying). So the Problem here is this one. It seems that the MarketPlaceService is working fine because it pop ups the buying message, but when you buy the developer product, the currency isn’t added to the leaderstats. Here I give you all the materials you need. I almost forget it, I think that, apart that this isnt working, This is really insecure and an exploiter can come and hack it. If you have any suggestion for this just leave it in the comments
MATERIALS

  • The leaderstats
local replicatedStorage = game:GetService("ReplicatedStorage")
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("LeaderboardSave")
local RemoteEvent = game.ReplicatedStorage.RemoteEvent

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder", player)
	leaderstats.Name = "leaderstats"
	
	local points = Instance.new("IntValue", leaderstats)
	points.Name = "Points"
	local HellCoins = Instance.new("IntValue", leaderstats)
	HellCoins.Name = "HellCoins"
	local HeavenCoins = Instance.new("IntValue", leaderstats)
	HeavenCoins.Name = "HeavenCoins"
	local AlienCoins = Instance.new("IntValue", leaderstats)
	AlienCoins.Name = "AlienCoins"
	
	local stats = ds:GetAsync(player.UserId)
	if stats ~= nil then
		points.Value = stats[1]
		HellCoins.Value = stats[2]
		HeavenCoins.Value = stats[3]
		AlienCoins.Value = stats[4]
	else
		stats = {0,0,0,0}
	end
end)
	

game.Players.PlayerRemoving:Connect(function(player)
	local save = {}
	table.insert(save, player.leaderstats.Points.Value)
	table.insert(save, player.leaderstats.HellCoins.Value)
	table.insert(save, player.leaderstats.HeavenCoins.Value)
	table.insert(save, player.leaderstats.AlienCoins.Value)
	ds:SetAsync(player.UserId, save)
end)

RemoteEvent.OnServerEvent:Connect(function(player, Value, Item) --
    player.leaderstats.Points.Value = player.leaderstats.Points.Value - Value
    game.ReplicatedStorage.Library[Item]:Clone().Parent = player:WaitForChild("Backpack")
end)
  • A script that is on the ServerScriptServer
local MPS = game:GetService("MarketplaceService")

MPS.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == "1022102502" then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 500
		return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == "1022102764" then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 700
		return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == "1022102923" then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 1000
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end
  • A local script on a Frame (ScreenGUI, StarterGUI)
MPS = game:GetService("MarketplaceService")
id = 1022102923

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

If you can help me I would be really greatfull.
Spideyalvaro999

2 Likes

Try to do this maybe?:

player:WaitForChild(“leaderstats”).HellCoins.Value = player:WaitForChild(“leaderstats”).HellCoins.Value + 700

This didn’t work. I don’t know what to do because everything seems to be good

Okay so, I tried the script, and it worked for me. What I did is I removed the speech marks (") on the dev product ID. And when I did the test purchase, it adds up to my leaderstats.

So what I did is:
if receiptInfo.ProductId == 1022102502 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 500
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == 1022102764 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 700
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == 1022102923 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 1000
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end

instead of:
local MPS = game:GetService(“MarketplaceService”)

MPS.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == “1022102502” then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 500
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == “1022102764” then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 700
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == “1022102923” then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 1000
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end

I will try it out and tell you if it worked for me

1 Like

Alright, hopefully it will work for you.

It doesnt work look I put it exactly like you:


You got an error right there. You forgot the:

local MPS = game:GetService(“MarketplaceService”)

MPS.ProcessReceipt = function(receiptInfo)

Yes I had try that but I got nothing. Do I have to eliminate the “” simboles from the gui buttons to? I have noticed that they dont have “” so I dont know

1 Like

If the DevProducID has “” , you need to remove it. But no need to remove “” for the MarketplaceService and for the DataStoreService. Only the Dev Product ID

I think I found the error give me a minute

I havent found anything and I did everything as you told me to do so I sont have a clue

I find this script disastrous, missing something more important than roblox asks
You can find out what it is asking for and examples of how to do it here
https://developer.roblox.com/en-us/articles/Developer-Products-In-Game-Purchases
I found this to
https://developer.roblox.com/en-us/api-reference/callback/MarketplaceService/ProcessReceipt

1 Like

Not sure why, but it works for me. https://gyazo.com/1e5933fa8fb27eb9912a3399338b7258

Im going to read it and tell you if I find anything
Thanks for the link :wink:

1 Like