Developer Product script help

Hi, I have been working on getting a developer product store to work properly. Currently it says the purchase is complete, it takes the robux from the player, but it does not give the rubies to the player. I have leaderstats defined in the script, but for some reason it does work.

Here is the serverscriptservice script and the button script I am using. Anyone see why they dont work?

I appreciate the help.

local MPS = game:GetService("MarketplaceService")

local player = game.Players.LocalPlayer
local leaderstats = game.Players.LocalPlayer.leadestats

local Functs = {}
Functs[1211021582] = function(player)
	player.leaderstats.Rubies.Value = player.leaderstats.Rubies.Value + 500
end
--Functs[1456783] = function(player)
--	player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 500
--end

MPS.PromptGamePassPurchaseFinished:Connect(function(player, Id, Purchase)
	if not Purchase then		return			end

	local Success, Err = pcall(Functs[Id], player)
	if not Success then			warn(Err)			end
end)

I disabled gold for now because there is no button for it. I’ll add it in when rubies work properly.


MPS = game:GetService("MarketplaceService")
id = 1211021582
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	MPS:PromptProductPurchase(player,id)
end)

Thanks a lot everyone.

try remove this code, this code only work on client

Thanks but it still doesnt work. I actually added that in an attempt to fix it thinking it might not know where to put the Rubies.

Its weird it should know exactly where to put the rubies, it just doesnt give me any.

local MPS = game:GetService("MarketplaceService")

local Data = {}
Data[1211021582] = 500
	
local function Rewards(player,Id)
	player.leaderstats.Rubies.Value = player.leaderstats.Rubies.Value + Data[Id]
end

MPS.PromptGamePassPurchaseFinished:Connect(function(player, Id, Purchase)
		if not Purchase then return	end  
		
		local Success, Err = pcall(Rewards(player,Id))
		end)
		
		if not Success then	warn(Err)			
		end
end)

Try this one first !

Same problem. Clicking says it is successful but does not grant any rubies.

Spent some time on this tonight and solved the issue with this script. Thanks everyone or you suggestions and input.

This is a working script.

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

local PreviousPurchases = DataStoreService:GetDataStore("PreviousPurcchases")

local buyrubies = 1211021582

MarketplaceService.ProcessReceipt = function(receipt)
	
	local ID = receipt.PlayerId.."-"..receipt.PurchaseId
	
	local success = nil
	
	pcall(function()
		success = PreviousPurchases:GetAsync(ID)
	end)
	
	if success then
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
	
	local player = game.Players:GetPlayerByUserId(receipt.PlayerId)
	
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
		
	else
		
		if receipt.ProductId == buyrubies then
			player.leaderstats.Rubies.Value = player.leaderstats.Rubies.Value + 500
			
		end
		
		pcall(function()
			PreviousPurchases:SetAsync(ID,true)
		end)
		return Enum.ProductPurchaseDecision.PurchaseGranted
		
	end
	
end

1 Like