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