Hi all, I'm entering the debug phase of my first build prior to an alpha release and I need a bit of guidance. I've looked around at all the other instances of a similar error but if someone more knowledgable than I could explain how to prevent it with regards to my scenario it would really help my learning going forward.
The context: I have a baseplate that I've turned into lava, in that I have a super basic script to kill characters that make contact with it.
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h ~= nil then
h.Health = 0
end
end
script.Parent.Touched:connect(onTouched)
However, in testing the game I get the following error every couple of seconds:
Workspace.Stages.1. lava.Baseplate.Script:3: attempt to index field 'Parent' (a nil value)
This is due to a series of boulders that roll down a slope and make contact with the baseplate before being removed from the game. I've tried a few of the solutions I've read to no avail (adding a wait() or simply defining the Parent to stop it being nil).
Just from writing this I realised it was the boulders causing the problem, which doesn't break the game, just floods the console making further debugging difficult. Any advice to help advance my learning would be greatly appreciated. Thanks

2 comments
That can happen when a bullet hits a part; the bullet changes it's parent to
nil(or when it's destroyed), or if something else causes that as well. The solution to check whether it's nil or not viaif part.Parent then.Thanks for the comment, I tried inserting a if part.Parent then which makes sense as a potential solution but then realised that the parts causing the issue were more than just the cloned boulders, there are moving platforms as well