Basically, my script is a mess of Tweens, is there a way i can shorten all of this?
local TweenService = game:GetService("TweenService")
game.Workspace.RightDoorEntrance.ClickDetector.MouseClick:Connect(function()
if workspace.RightDoorEntrance.isOpened.Value == false then
workspace.RightDoorEntrance.isOpened.Value = true
local tweenInf = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local Properties = {CFrame = CFrame.Angles(0, 80, 0) + Vector3.new(-12.098, 57.8, 84.168)}
TweenService:Create(game.Workspace.RightDoorEntrance.Part, tweenInf, Properties):Play()
TweenService:Create(game.Workspace.RightDoorEntrance.Union, tweenInf, Properties):Play()
TweenService:Create(game.Workspace.RightDoorEntrance.MeshPart2, tweenInf, Properties):Play()
local Propteries2 = {CFrame = CFrame.Angles(0, 180, 0) + Vector3.new(-12.098, 57.8, 84.168)}
TweenService:Create(game.Workspace.RightDoorEntrance.MeshPart1, tweenInf, Propteries2):Play()
TweenService:Create(game.Workspace.RightDoorEntrance.MeshPart2, tweenInf, Propteries2):Play()
else
workspace.RightDoorEntrance.isOpened.Value = false
print("Door is opened, closing")
local tweenInf = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local backProperties = {CFrame = CFrame.Angles(0, math.rad(-180), 0) + Vector3.new(-13.914, 57.8, 81.729)}
TweenService:Create(game.Workspace.RightDoorEntrance.Part, tweenInf, backProperties):Play()
TweenService:Create(game.Workspace.RightDoorEntrance.Union, tweenInf, backProperties):Play()
TweenService:Create(game.Workspace.RightDoorEntrance.MeshPart2, tweenInf, backProperties):Play()
end
end)
game.Workspace.LeftDoorEntrance.Part.ClickDetector.MouseClick:Connect(function()
if workspace.LeftDoorEntrance.isOpened.Value == false then
workspace.LeftDoorEntrance.isOpened.Value = true
local tweenInf = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local Properties = {CFrame = CFrame.Angles(0, 80, 0) + Vector3.new(-20.844, 57.8, 83.596)}
TweenService:Create(game.Workspace.LeftDoorEntrance.Part, tweenInf, Properties):Play()
TweenService:Create(game.Workspace.LeftDoorEntrance.Union, tweenInf, Properties):Play()
TweenService:Create(game.Workspace.LeftDoorEntrance.MeshPart2, tweenInf, Properties):Play()
local Propteries2 = {CFrame = CFrame.Angles(0, -180, 0) + Vector3.new(88.95, 168.26, 78.28)}
TweenService:Create(game.Workspace.LeftDoorEntrance.MeshPart, tweenInf, Propteries2):Play()
TweenService:Create(game.Workspace.LeftDoorEntrance.MeshPart2, tweenInf, Propteries2):Play()
else
-- CLOSE THE DOOR
workspace.LeftDoorEntrance.isOpened.Value = false
print("Door is opened, closing")
local tweenInf = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local backProperties = {CFrame = CFrame.Angles(0, math.rad(360), 0) + Vector3.new(-18.154, 57.8, 81.826)}
TweenService:Create(game.Workspace.LeftDoorEntrance.Part, tweenInf, backProperties):Play()
TweenService:Create(game.Workspace.LeftDoorEntrance.Union, tweenInf, backProperties):Play()
TweenService:Create(game.Workspace.LeftDoorEntrance.MeshPart2, tweenInf, backProperties):Play()
local Propteries2 = {CFrame = CFrame.Angles(0, -180, 0) + Vector3.new(-19.807, 57.741, 84.707)}
TweenService:Create(game.Workspace.LeftDoorEntrance.MeshPart, tweenInf, Propteries2):Play()
TweenService:Create(game.Workspace.LeftDoorEntrance.MeshPart2, tweenInf, Propteries2):Play()
end
end)
--inDoorEntrance
game.Workspace.inEntrLeftDoor.Part.ClickDetector.MouseClick:Connect(function()
if workspace.inEntrLeftDoor.isOpened.Value == false then
workspace.inEntrLeftDoor.isOpened.Value = true
local enIntrLeftDoorPr = game.Workspace.inEntrLeftDoor
local tweenInf = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local Properties = {CFrame = CFrame.Angles(0, math.rad(180), 0) + Vector3.new(-28.571, 57.8, 75.582)}
TweenService:Create(enIntrLeftDoorPr.Part, tweenInf, Properties):Play()
TweenService:Create(enIntrLeftDoorPr.Union, tweenInf, Properties):Play()
TweenService:Create(enIntrLeftDoorPr.MeshPart2, tweenInf, Properties):Play()
else
workspace.inEntrLeftDoor.isOpened.Value = false
print("Closing door")
local enIntrLeftDoorPr = game.Workspace.inEntrLeftDoor
local tweenInf = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local Properties = {CFrame = CFrame.Angles(0, math.rad(90), 0) + Vector3.new(-26.421, 57.8, 73.492)}
TweenService:Create(enIntrLeftDoorPr.Part, tweenInf, Properties):Play()
TweenService:Create(enIntrLeftDoorPr.Union, tweenInf, Properties):Play()
TweenService:Create(enIntrLeftDoorPr.MeshPart2, tweenInf, Properties):Play()
end
end)

3 comments
tables
Have one primary part and weld all other parts to it using Welds (Make sure they are unanchored and only primary part Anchored), This will make all of the welded parts follow the primary one
V a r i a b l e s and f u n c t i o n s