Cannot get my kill Tool to work

That is my script and it is suppost to give me and only me a tool which when activated kills everyone but me in the game . I think it went wrong because of the tools Parents though .

Here’s the script if you cannot see it clearly

game.Players.PlayerAdded:Connect(function(plr)

if plr.Name == "GHVHJGFJDUC" or plr.Name == "Player1" then	
local MyClone = script.Parent:Clone()
MyClone.Parent = plr:FindFirstChild("Backpack")
	

	script.Parent.Activated:Connect(function()
	local MyWorkSpace = game.Workspace:GetChildren()
		
		for i,v in pairs(MyWorkSpace) do
				
			if v:IsA("Model") then
					
				if v.Name ~= "Player1" or v.Name ~= "GHVHJGFJDUC" then				
				v:FindFirstChild("Humanoid").Health = 0
			
				end
			end
		end
	end)
end

end)

You can’t kill everyone but you with a local script, put the player added part that gives you the tool in the server script, and in the local script, put the activated function, and fire a remote event for the server to kill all of the players. And instead of going through all of the workspace children, go through all of the players, and through their character get the humanoid and kill them.

It would not error because i have said that it will only run if the models name is a players name . For example when a player joins there model name would be Player1

A exploiter can manipulate the remote event, fire it many times and pass their own arguments. Not a good way at all.

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

Yup, did. Thanks for letting me know.

1 Like

guys it’s fine . Also The script works perfectly . It is only putting it in the backpack which does not work .

1 Like

When I try make it so this tool can only be used by me and player1 it does not work but otherwise it does

Let me fix it. :slight_smile: No worries at all!

PlayerService.PlayerAdded:Connect(function(Player)
    if Player.Name == not OwnerName then return end
     print("True")
    Tool:Clone().Parent = Player.Backpack
end)

The tool will only clone to your backpack, not player 1.

Ok thanks . Ill give you the working script rq .

	script.Parent.Activated:Connect(function()
	local MyWorkSpace = game.Workspace:GetChildren()
		
		for i,v in pairs(MyWorkSpace) do
				
			if v:IsA("Model") then
					
				if v.Name ~= "Player1" and v.Name ~= "GHVHJGFJDUC" then				
				v:FindFirstChild("Humanoid").Health = 0
			
				end
			end
		end
	end)

it makes no difference because even if one of them is not in the game that makes it so cannot be one of them . It is hard to explain but it does the same
as or .

Still, use or. It is much better.

Sorry but or actually breaks the script and makes it kill every player including player1

Completely false assumption.

if v.Name ~= "Player1" or v.Name ~= "GHVHJGFJDUC" then

Tell me how can you say that v’s name can be Player1 and GHVHJGFJDUC at the same time. And or checks if the player’s name is NOT Player1 or GHVHJGFJDUC. And will check if the player’s name is both Player1 and GHVHJGFJDUC.

I do not really know but the script only works with an and

Yes, because you have constructed it that way. Just don’t make false assumptions regarding or and and.

What is wrong with using and? I can’t really understand why or won’t work but can understand why and can .

Wait i actually can understand why or will not work . It is because if my name is GHVHJGFJDUC then it is not = Player1 and the script will kill me anyway . This goes the other way around as well

Issues

game.Players.PlayerAdded is only for when the player is added

script.Parent.Touched:Connect(function(hit) -- this shold be inside the handle

      local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
      if plr and plr.Character and plr.Name == "YOURNAMEHERE" then
           plr.Character.Humanoid:TakeDamage(10) -- change 10 to your damage
      end
end)