Trying to make the check that will prevent the script from breaking when a bullet hits the brick.
script.Parent.Touched:connect(function(hit)
if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
script.Parent.Touched:connect(function(hit)
if hit.Parent then
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end
end)
I'm more inclined to use the first option, because it's cleaner, but I was worried that in the case hit.Parent doesn't exist, the part where it looks for a Humanoid would error because it assumes hit.Parent does exist. Therefore I'm not sure. Which one should I use? Please explain why I should use that particular option in your answers. Thanks.

2 comments
Ooohhhhh thanks a lot.
Lua's lazy evaluation of
andandoris also the secret to the "ternary" operator: x = conditional and valueIfTrue or valueIfFalse