This is a script from an owner only door, but there are aliens in my game that I would like to be killed from the lasers too. I tried deleting the "plr" part so that it would just set all humanoids health to zero ,and I tried just identifying an alien also as a plr by using
game. Aliens.("Alien")
but that didn't work either. I am new to scripting so sorry if I am doing this completely wrong, but what is the most efficient way of doing this?
val = script.Parent.Parent.Parent.Value function touc(part) local plr = game.Players:FindFirstChild(part.Parent.Name) if plr then local h = part.Parent:FindFirstChild("Humanoid") if h then if val.Value == true then if part.Parent.Name ~= script.Parent.Parent.Parent.Parent.Parent.Owner.Value.Character.Name then h.Health = 0 end end end end end script.Parent.Touched:connect(touc)
What you can do is, if the alien has a humanoid in it
val = script.Parent.Parent.Parent.Value -- guessing this is if it is on or not? function touc(part) if val.Value == true then -- check to see if it is on if part.Parent then -- check to see if it has a parent if part.Parent:FindFirstChild("Humanoid") then local humanoid = part.Parent:FindFirstChild("Humanoid") if part.Parent.Name ~= script.Parent.Parent.Parent.Parent.Parent.Owner.Value.Character.Name then humanoid.Health = 0 end end end end end script.Parent.Touched:Connect(touc)