Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.