I'm making zombies that takes damage when a player touches them and when the zombies detect their humanoid, but my problem is that the zombies have a humanoid has well. So when they are coming towards me and they touch each other, they take damage as well. How can I make it so that only the players take damage from them instead of them being able to kill each other?
Just to clarify, this does kill players AND zombies but I want it to only kill players.
Script inside of "LeftLowerArm" and "RightLowerArm"
function onTouched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) and (human.Parent.Name ~= "RoboZombie") then
human.Health = human.Health - 5
end
end
script.Parent.Touched:connect(onTouched)

1 comment
add in the if statement and game.Players:GetPlayerFromCharacter(hit.Parent)