Basically making a tool that can ONLY damage "Enemy", works perfectly until the "Enemy"'s health goes to zero, and all the other Humanoid's health that are NOT "Enemy" is also set to zero, and the outpost doesn't say anything, maybe I'm doing something wrong?, not too sure.
local weapon = script.Parent local damage = 25 weapon.Touched:Connect(function(TouchedPart) if TouchedPart ~= script.Parent.Parent.Parent then if TouchedPart.Parent:FindFirstChild("Enemy") then local Enemy = TouchedPart.Parent:FindFirstChild("Enemy") Enemy:takeDamage(25) end end end)
Any help would be appreciated, thanks!
If the Humanoid is Named Enemy then
local weapon = script.Parent local damage = 25 weapon.Touched:Connect(function(TouchedPart) if TouchedPart ~= script.Parent.Parent.Parent then if TouchedPart.Parent:FindFirstChild("Enemy") then local Enemy = TouchedPart.Parent:FindFirstChild("Enemy") --finds humanoid Enemy.Health = Enemy.Health - damage --takes away damage end end end)
If the Humanoid is Called Humanoid
local weapon = script.Parent local damage = 25 --the damage it will take away weapon.Touched:Connect(function(TouchedPart) if TouchedPart ~= script.Parent.Parent.Parent then if TouchedPart.Parent:FindFirstChild("Enemy") then if TouchedPart.Parent:FindFirstChild("Humanoid") then --finds humanoid local Humanoid = TouchedPart.Parent:FindFirstChild("Humanoid") Humanoid.Health = Humanoid.Health - damage --takes away damage end end end)
You also had the local damage which wont change anything but now it will take away the damage you set at the top