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)
Try
function onTouched(hit) if hit.Name == "RedUnit" or 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)