I’m trying to make a damage script I whipped up not damage a certain player, how do i acheive this, code below.
It finds the player who hits its humanoid, how do I intercept it by checking if the player that hit it is the player that shouldnt hit it, I know about the return function, I just dont know how to set this up.
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
human.Health = human.Health - math.huge -- Change the amount to change the damage.
wait(0.1)
human:Destroy()
end
end
script.Parent.Touched:connect(onTouched)
if hit.Parent:findFirstChild("Humanoid").Parent.Name == "Player" then
return
end
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
human.Health = human.Health - math.huge -- Change the amount to change the damage.
wait(0.1)
human:Destroy()
end
end
script.Parent.Touched:connect(onTouched)
Sorry, but I don’t get what you were trying to do still? I see taht your scripts checks if the hit part has a humanoid in it, but after if it hasn’t you make a variable for the humanoid? It doesn’t make sense to me sorry