Why won't my developer products work?!

I’m trying to make a Kill All Players & Points, & Rubys in my leaderstats. I’ll add one product, and it will work, but if I add more than one, it won’t work at all (in the same script). I’m wondering if it is the Third Party Sales Settings in the Game Settings, or the Premium benefits in my game affecting it, but please help soon.

Kill All Players Script:

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

-- Kill All Players Product

MPS.ProcessReceipt = function(recipt)
	if recipt.ProductId == 1265558086 then
		for i, v in pairs(Players:GetPlayers()) do
			if v.UserId ~= recipt.PlayerId and v.Character and v.Character:FindFirstChild("Humanoid") then
				v.Character:FindFirstChild("Humanoid").Health = 0
			end
		end

		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

Points and Rubies Script:

MPS.ProcessReceipt = function(recipt)
	local plr = Players:GetPlayerByUserId(recipt.PlayerId)
	if recipt.ProductId == 1266497790 then
		plr.leaderstats.Rubys.Value = plr.leaderstats.Rubys.Value + 50
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

Sincerely, papahetfan

1 Like

Are you using 2 different scripts?

Is item sale turned on because passes cant be free

Yes. I’m working on making it in only 1 script.

You can’t assign more than one callback function to MarketplaceService.ProcessReceipt.

1 Like

You can’t set ProcessReceipt more than one time.

Alright, how can I fix that problem?

You should make like this:

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

-- Kill All Players Product

MPS.ProcessReceipt = function(recipt)
	if recipt.ProductId == 1265558086 then
		for i, v in pairs(Players:GetPlayers()) do
			if v.UserId ~= recipt.PlayerId and v.Character and v.Character:FindFirstChild("Humanoid") then
				v.Character:FindFirstChild("Humanoid").Health = 0
			end
		end

		return Enum.ProductPurchaseDecision.PurchaseGranted
else
 if recipt.ProductId == 1266497790 then
		plr.leaderstats.Rubys.Value = plr.leaderstats.Rubys.Value + 50
		return Enum.ProductPurchaseDecision.PurchaseGranted
	 end
	end
end

Now I got an Error saying attempt to index nil with ‘leaderstats’

here is my code:

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

-- Kill All Players Product

MPS.ProcessReceipt = function(recipt)
	if recipt.ProductId == 1265558086 then
		for i, v in pairs(Players:GetPlayers()) do
			if v.UserId ~= recipt.PlayerId and v.Character and v.Character:FindFirstChild("Humanoid") then
				v.Character:FindFirstChild("Humanoid").Health = 0
			end
		end

		return Enum.ProductPurchaseDecision.PurchaseGranted
	else
		if recipt.ProductId == 1266497790 then
			player.leaderstats.Rubys.Value = player.leaderstats.Rubys.Value + 50
			return Enum.ProductPurchaseDecision.PurchaseGranted
		end
	end
end

ProcessReciept must be in a ServerScript.

It already is in ServerScriptService

Can I use a FindFirstChild function?

Then you cant get LocalPlayer.

so then how can I fix that issue?

Try

local MPS = game:GetService("MarketplaceService")
local Players = game:GetService("Players ")


MPS.ProcessReceipt = function(recipt)
	if recipt.ProductId == 1265558086 then
		for i, v in pairs(Players:GetPlayers()) do
			if v.UserId ~= recipt.PlayerId and v.Character and v.Character:FindFirstChild("Humanoid") then
				v.Character:FindFirstChild("Humanoid").Health = 0
			end
		end

		return Enum.ProductPurchaseDecision.PurchaseGranted
else
 if recipt.ProductId == 1266497790 then

local plr = Players:GetPlayerByUserId(recipt.PlayerId)

		plr.leaderstats.Rubys.Value = plr.leaderstats.Rubys.Value + 50
		return Enum.ProductPurchaseDecision.PurchaseGranted
	 end
	end
end
1 Like

Guess what, it works! Thank you so much!

1 Like