Im trying to make a kitchen counter with doors that can open, However when i test the game and click the door it says: "Attempt to call a nil value" Why does this happen, And how can i fix it? Code:
script.Parent.Door1.ClickDetector.MouseClick:connect(Door1Open)
script.Parent.Door2.ClickDetector.MouseClick:connect(Door2Open)
script.Parent.Door1Open.ClickDetector.MouseClick:connect(Door1Close)
script.Parent.Door2Open.ClickDetector.MouseClick:connect(Door2Close)
function Door1Open()
script.Parent.Door1.Transparency = 1
script.Parent.Door1Open.Transparency = 0
end
function Door2Open()
script.Parent.Door2.Transparency = 1
script.Parent.Door2Open.Transparency = 0
end
function Door1Close()
script.Parent.Door1.Transparency = 0
script.Parent.Door1Open.Transparency = 1
end
function Door2Close()
script.Parent.Door2.Transparency = 0
script.Parent.Door2Open.Transparency = 1
end
Also, Im quite new to this programming thing. So try to simplify answers as much as possible. Thank you.

6 comments
it will attempt to do all of the functions at once so try to make it into one, also you have to define the functions before calling them
Ok, Thanks.
But wait... When i click one thing only one function runs. Not all.
Tried it, Didn't work.
Or you didn't define correctly the location of the doors that's why it appears as nil (non existant)
Can you share your hierarchy?