I am trying to make an elevator that has sliding doors I am storing the elevator model in ReplicatedStorage and cloning the model to a generated map. (this is done in another script)
The elevator doors / button are children of the elevator model.

The elevator model retains its origin position when it is in ReplicatedStorage.

The problem that I am having is when I try to animate the elevator doors. SInce the elevator is cloned and then moved to a random location on my generated map, I need the doors to move relative to their current position.
When I use TweenService to animate the doors, they don’t move +4 or -4 studs as expected. Instead, they fly off into the distance towards the Origin Position that the model was originally located at.
This code works as expected when the model is not cloned from ReplicatedStorage and moved to a new location, and the elevator doors animate normally, i.e. when the model is normally placed in the Workspace. What is going on here?
Here is the code that I am using to animate the doors:
local tweenService = game:GetService("TweenService")
-- Objects associated with the elevator
local clickDetector = script.Parent.ClickDetector
local elevator_left_door = script.Parent.Parent.elevator_door1
local elevator_right_door = script.Parent.Parent.elevator_door2
-- Details about how the elevator door animation will be played
local tweenInfo = TweenInfo.new(
5, --Duration in seconds
Enum.EasingStyle.Linear, --EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
1 -- DelayTime in seconds
)
-- End point for the door movement
local tween_goal_left = {Position = elevator_left_door.Position + Vector3.new(-4,0,0)}
local tween_goal_right = {Position = elevator_right_door.Position + Vector3.new(4,0,0)}
-- Creates an object that can move the elevator doors
local tween_left = tweenService:Create(elevator_left_door,tweenInfo,tween_goal_left)
local tween_right = tweenService:Create(elevator_right_door,tweenInfo,tween_goal_right)
-- Open the elevator doors when the elevator button is clicked by the player
clickDetector.MouseClick:Connect(function()
tween_left:Play()
tween_right:Play()
end)
Is there a way I can get the current position of the elevator doors? It seems like the Position property that I am using is getting the original position of the doors, and not their position after the Model is cloned to a new location.
Also, is there a better place to store models than ReplicatedStorage for this use case?