Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

In a regular lava brick why do you put if hit.Parent then?

Asked by
duckyo01 120
9 years ago

Why would you put

local lava = script.Parent
script.Parent.Touched:connect(function(hit)
if hit.Parent then
local guy = hit.Parent:FindFirstChild('Humanoid')
if guy then
guy.Health = 0
end
end)

Whats the point of the

if hit.Parent then

1 answer

Log in to vote
3
Answered by 9 years ago

Sometimes a hit can have a nil parent, it's just a fail-safe to ensure it won't error if hit doesn't have a parent.

Ad

Answer this question