Any better ways to tween/slide parts?

Alright, currently I’m making a sliding interactable door for a group. It’s completely local at the Client’s request however I’ve come into an issue when rotating the door. Since I’m only changing the X Axis, when you rotate it, the door goes wild.

Is there any better ways of tweening the part so that it doesn’t go wild when they rotate it?


local PlayerService = game:GetService('Players');
local UserInputService = game:GetService('UserInputService');
local TweenService = game:GetService('TweenService');
--------------------------------------------------
local LocalPlayer = PlayerService.LocalPlayer;
--------------------------------------------------
local InteractUI = LocalPlayer.PlayerGui:WaitForChild('InteractUI');
--------------------------------------------------
local StaffDoors = {
	
	["Administration"] = LocalPlayer.Team.Name, -- To add more teams, just duplicate and change "Administration"
	
	
	}

-------------------------------------------------- Door Tween Configuration

local TweenInformation = TweenInfo.new(
	
	1, -- Speed/Seconds
	Enum.EasingStyle.Linear, -- Don't Touch
	Enum.EasingDirection.Out, -- Don't Touch
	0, -- Don't Touch
	false , -- Don't Touch
	0 -- Don't Touch
	)

local MoveStudAmount = 4.3
local NewCFrame
local AbleToInteract = true -- Don't touch this unless you want tween bugs :)
--------------------------------------------------

while true do
	wait(0.01)
	local Mouse = LocalPlayer:GetMouse()
	local Target = Mouse.Target
	local Team = LocalPlayer.TeamColor
	if Target ~= nil then
		
		InteractUI.Enabled = true
		if Target.Parent:IsA('Model') and Target.Parent.Name == "MetalDoor" then
			if LocalPlayer.Team.Name == StaffDoors[LocalPlayer.Team.Name] then
				UserInputService.InputBegan:Connect(function(Input)
					if Input.UserInputType == Enum.UserInputType.Keyboard and Input.KeyCode == Enum.KeyCode.E then
						local Status = Target.Parent.Status.Value
						if Status == true then
							if AbleToInteract == true then
								AbleToInteract = false
								Target.Parent.Door.CanCollide = false
								local DoorXCFrame = Target.Parent.Door.CFrame.X
								DoorXCFrame = DoorXCFrame + MoveStudAmount
								NewCFrame = {CFrame = CFrame.new(DoorXCFrame, Target.Parent.Door.CFrame.Y,Target.Parent.Door.CFrame.Z)}
								local DoorTween = TweenService:Create(Target.Parent.Door,TweenInformation,NewCFrame)
								DoorTween:Play()
								Target.Parent.Green.Material = Enum.Material.Neon
								Target.Parent.Red.Material = Enum.Material.Metal
								DoorTween.Completed:wait()
								Target.Parent.Status.Value = false
								AbleToInteract = true
							end
						elseif Status == false then
							if AbleToInteract == true then
								AbleToInteract = false
								Target.Parent.Door.CanCollide = true
								local DoorXCFrame = Target.Parent.Door.CFrame.X
								DoorXCFrame = DoorXCFrame - MoveStudAmount
								NewCFrame = {CFrame = CFrame.new(DoorXCFrame, Target.Parent.Door.CFrame.Y,Target.Parent.Door.CFrame.Z)}
								local DoorTween = TweenService:Create(Target.Parent.Door,TweenInformation,NewCFrame)
								DoorTween:Play()
								Target.Parent.Green.Material = Enum.Material.Metal
								Target.Parent.Red.Material = Enum.Material.Neon
								DoorTween.Completed:wait()
								AbleToInteract = true
								Target.Parent.Status.Value = true
							end
						end
					end
				end)
			end
		else
			InteractUI.Enabled = false
		end
	end
end

https://gyazo.com/4986a8aeaa1e03c25a13e54a8d87c8b6

I assume this would be of use to you.

Tip
Use and in if statements to compile conditions.
You can also just say if var then and if the var is a boolean it’ll work too.