I made a script for one door, it worked fine, but when I made the same script for the second door, it moved to the first door. How can I make these be different scripts for doors? and another question is what will happen if the train leaves, will the door remain in the same position? if anyone knows, please help
You probably haven’t updated the position of the second door to its correct value, so it is still acting as the first door and positioning itself over there. As for if the train moves, it will probably not bring the doors with it; because you are directly setting the position of the doors, and this position isn’t changed when the train moves. I think a better course would to be use HingeConstraints
Instead of hard coding values you can use a motor6d and change its desired angle value. If you are going to use those doors in multiple places put the code in a module script then require() it from a server script inside the door this way you wont need to update hundred door scripts just to fix a single bug.
And to answer the question, The door teleports to the other door because you hardcoded the position which makes the other door go there.
Depends on how they want the doors to behave. HingeConstraints when you want the doors to have physics, otherwise use a Motor6D and change its Desired Angle value.