I have a button in my game where if a user clicks it then it will prompt a purchase which works but what doesn’t work is it is supposed to kill everyone accepts for the person that is purchasing it.
This is the ServerScript that is placed in ServerScriptService:
local mps = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local DevProductId = 1255384268
local function killAll(reciept)
if (reciept.ProductId == DevProductId) then
for i,v in pairs(game.Players:GetPlayers()) do
if(v.UserId ~= reciept.PlayerId and v.Character and v.Character:FindFirstChild("Humanoid")) then
v.Character:FindFirstChild("Humanoid").Health = 0
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
mps.ProcessReceipt = killAll
local function killAll(reciept)
print("invoked callback")
if (reciept.ProductId == DevProductId) then
print("player bought the right product")
for i,v in pairs(game.Players:GetPlayers()) do
if(v.UserId ~= reciept.PlayerId and v.Character and v.Character:FindFirstChild("Humanoid")) then
v.Character:FindFirstChild("Humanoid").Health = 0
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
mps.ProcessReceipt = killAll
Continue adding prints after almost every statement/function, that’s a way to debug and see where the script stops also do you get any errors in the console?