Hello everyone! i was doing a door system,but it didn’t work,the output said: Workspace.KeyDoor.Script:4: attempt to index nil with ‘Parent’ The code:
local door = script.Parent function DoorDestroy(hit) if hit.Parent.Name == door.DoorKey.Value then door.Lock.Anchored = false wait(1) door:Destroy() end end door.PrimaryPart.Touched:Connect(DoorDestroy())
local door = script.Parent
function DoorDestroy(hit) if hit.Parent.Name == door.DoorKey.Value then door.Lock.Anchored = false wait(1) door:Destroy() end end
door.PrimaryPart.Touched:Connect(DoorDestroy())
local door = script.Parent function DoorDestroy(hit) if hit.Parent.Name == door.DoorKey.Value then door.Lock.Anchored = false wait(1) door:Destroy() end end door.PrimaryPart.Touched:Connect(DoorDestroy) -- just type the function name, don't call it
Which line is the error occurring on?
The line that’s having the error is 4.
nil basically means nothing so you might have nothing as the value. (or something doesn’t exist.)