Hello, I'm making a model with Touched And TouchEnded to set a value to true or false, then it fire projectiles, but everytime that the enemy dies and fire the TouchEnded function, this happens:
17:52:29.469 - Workspace.Model.Touch:9: attempt to index field 'Parent' (a nil value)
Script:
function OnTouch(Hit)
local Check = Hit.Parent:FindFirstChild("Zombie")
if Check then
script.Parent.Value.Value = true
end
end
function OnTouchEnded(Hit)
local Check = Hit.Parent:FindFirstChild("Zombie")
if Check then
script.Parent.Value.Value = false
end
end
script.Parent.Part1.Touched:connect(OnTouch)
script.Parent.Part1.TouchEnded:connect(OnTouchEnded)
If theres any way to solve it, Please tell me. Thanks!
PS: The enemy gets removed when her Died function fires, then that happens.

3 comments
Could it be that on line 9 it checks for "zombie" but zombie doesn't exist anymore so it gets a nil value?
Ya i think thats it, i just don't know how to fix that way
use an if statement instead of assigning it to variable first. Because if it doesn't exist it will just throw an error