16:31:49.116 - Workspace.GameFiles.RedFile.WalkPoints.Gem.Head.ObjectiveTest:2: attempt to index field 'Parent' (a nil value)
function onTouched(hit)
if hit.Parent.Name == "RedUnit" then
script.Parent.Parent.Humanoid.Health = script.Parent.Parent.Humanoid.Health - 20
hit.Parent:Destroy()
end
end
connection = script.Parent.Touched:Connect(onTouched)

6 comments
Does 'hit.Name' work instead of 'hit.Parent.Name'?
i tried that and it didnt sadly.
I forgot to mention the script actually works perfectly but this error comes up, its rather weird.
It just happens because sometimes the hit object is from something other than "RedUnit" and apparently doesn't have Parent of it's Parent. If this bothers you just make a check to determine if hit.Parent has a humanoid before changing it's health.
The only thing hitting it is body parts of a naked npc, so i dont think thats the problem
I had that problem a while ago, strangely it stopped after a while. Could it be the newest ROBLOX update?