Need some help with this kill brick. I dont want the brick to kill me even when I unequip the tool

I got something working but its not killing the other player also not killing me

Here is the script:

Part.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid and hit.Parent ~= tool.Parent and not hit.Parent:IsDescendantOf(plr) then
		humanoid.Health -= 12
	end
end)

this is a method I tried using but it doesn’t kill the other players and i also take no damage which is good but i want the other {players} to take damage

here is a example of what is happening when i unequip the tool

How is plr defined? The character isn’t a descendant of the player, it’s a property of the player.

Can you provide the full script?

1 Like

oh yeah sorry about that i thought people would know that I can get the player from the tool by using
game.Players:GetPlayerFromCharater(tool.Parent)

tool.Activated:Connect(function()
	local plr = game.Players:GetPlayerFromCharacter(tool.Parent)
	if os.clock() > clock then
		clock = os.clock() + DeTime
		
		local Part = makePart(plr)  -- i returned a part from this function

		Part.Touched:Connect(function(hit)
			local humanoid = hit.Parent:FindFirstChild("Humanoid")
			if humanoid and hit.Parent ~= tool.Parent and not hit.Parent:IsDescendantOf(plr) then
				humanoid.Health -= 12
			end
		end)
	
		
	end
end)

Try using a remote event. Only the client will be affected by the part.

Found the issue

	part.Touched:Connect(function(hit)
			local humanoid = hit	.Parent:FindFirstChild("Humanoid")
			if humanoid and humanoid ~= plrHumanoid  then
				humanoid:TakeDamage(30)
				print(hit.Parent)
			end
		end)

The issue was when the tool was Unequipped the tool.Parent will no longer be the Current player
so i stored it in a variable and compared the humanoid to the plrHumanoid instead of hit.Parent

1 Like

Good job,

Here’s what happens when the player unequips a tool:
-The parent is being changed to nil or Backpack [ depends].

You could always make a boolean value to set to true/false for e.g when you’ve a tool equipped on, and with that, you can do different things.

Best wishes!

1 Like