(HELP) Kill All Dev Product Not Working

Hello! I was creating a developer product script. One of the products sells the option to skip a stage (it works well), while the other is the kill all function, which I’m having a hard time getting to work.

Does anyone know how I can fix this? Thanks!

function processReceipt(info)
	local plr = game:GetService("Players"):GetPlayerByUserId(info.PlayerId)

	if plr then
		if info.ProductId == 2636822786 then
			plr.Character.Humanoid.Health = 0
			local stats = plr:WaitForChild("leaderstats")
			local changeStage = stats and stats:FindFirstChild("Stage")
			if changeStage then
				changeStage.Value +=1
				game.Workspace.SoundEffects.LevelUp:Play(plr)
			end
			
		elseif info.ProductId == 2651471576 then
local playa = game.Players:GetPlayerByUserId(info.PlayerId)
					for i, playa in ipairs(game.Players:GetChildren()) do
						if playa ~= playa then
							playa.Character.Humanoid.Health = 0
						end
					end
				end
		return Enum.ProductPurchaseDecision.PurchaseGranted
	else
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
end

game:GetService("MarketplaceService").ProcessReceipt = processReceipt

This line here is causing the issue (line 17 of the code snippet).
You are checking if an object is not equal to itself, which is always going to be false.
I believe you intended for one of these to be plr

2 Likes

Try using player.Name ~= playa.Name instead.

if plr then
	if info.ProductId == 2636822786 then
		plr.Character.Humanoid.Health = 0
		local stats = plr:WaitForChild("leaderstats")
		local changeStage = stats and stats:FindFirstChild("Stage")
		if changeStage then
			changeStage.Value +=1
			game.Workspace.SoundEffects.LevelUp:Play(plr)
		end

	elseif info.ProductId == 2651471576 then
		for i, otherplr in ipairs(game.Players:GetChildren()) do
			if otherplr ~= plr and otherplr.Character then
				otherplr.Character.Humanoid.Health = 0
			end
		end
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
else

i changed the part where it loops through the players to kill them

1 Like

Thanks for the help! The script is working now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.