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
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
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
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