16:31:49.116 - Workspace.GameFiles.RedFile.WalkPoints.Gem.Head.ObjectiveTest:2: attempt to index field 'Parent' (a nil value)
1 | function onTouched(hit) |
2 | if hit.Parent.Name = = "RedUnit" then |
3 | script.Parent.Parent.Humanoid.Health = script.Parent.Parent.Humanoid.Health - 20 |
4 | hit.Parent:Destroy() |
5 | end |
6 | end |
7 |
8 | 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)