Sliding door models but primary parts a pain

I’ve been trying to make 2 doors slide for the past 3 hours and eventually had to implement PrimaryPart good old stuff into them. I did what I do best, hope that things work and fix any errors, but I’m not too sure on this error. If anyone could help, much appreciated. Code below.

local tween = game:GetService("TweenService")
local doorModel = workspace.DoubleDoors.One
doorModel.Left.PrimaryPart = doorModel.Left.Primary
doorModel.Right.PrimaryPart = doorModel.Right.Primary
local left = doorModel.Left
local right = doorModel.Right

local tiInfo = TweenInfo.new(0.5)
local leftGoalOpen = {}
local leftGoalClose = {}
local rightGoalOpen = {}
local rightGoalClose = {}

leftGoalOpen:PivotTo(left.PrimaryPart, left.PrimaryPart.CFrame * CFrame.new(left.PrimaryPart.Size.X, 0, 0))
leftGoalClose:PivotTo(left.PrimaryPart, left.PrimaryPart.CFrame)
local leftOpen = tween:Create(left, tiInfo, leftGoalOpen)
local leftClose = tween:Create(left, tiInfo, leftGoalClose)

rightGoalOpen:PivotTo(right.PrimaryPart, right.PrimaryPart.CFrame * CFrame.new(-right.PrimaryPart.Size.X, 0, 0))
rightGoalClose:PivotTo(right.PrimaryPart, right.PrimaryPart.CFrame)
local rightOpen = tween:Create(right, tiInfo, rightGoalOpen)
local rightClose = tween:Create(right, tiInfo, rightGoalClose)

script.Parent.Lock:GetPropertyChangedSignal("Value"):Connect(function()
	if script.Parent.Lock.Value == true then
	doorModel.Proximity.Open.Enabled = false
	if doorModel.Proximity.Open.ActuallyOpen.Value == true then
		doorModel.Proximity.Open.ActuallyOpen.Value = false
		rightGoalClose:Play()
		leftGoalClose:Play()
			doorModel.Left.LeftNeon.Color = Color3.fromRGB(255, 0, 0)
			doorModel.Right.RightNeon.Color = Color3.fromRGB(255, 0, 0)
		end
	else
		doorModel.Proximity.Open.Enabled = true
		doorModel.Left.LeftNeon.Color = Color3.fromRGB(255, 255, 255)
		doorModel.Right.RightNeon.Color = Color3.fromRGB(255, 255, 255)
	end
end)

game:GetService("ServerStorage").Controls.Power:GetPropertyChangedSignal("Value"):Connect(function()
	if game:GetService("ServerStorage").Controls.Power.Value == true then
		local surfacegui = script.Parent.SurfaceGui
		local status = surfacegui.STATUS
		local text = surfacegui.TEXT
		
		if status.TextColor3 == Color3.fromRGB(126, 255, 244) then return warn("Cannot start while already started") end
		
		status.TextColor3 = Color3.fromRGB(126, 255, 244)
		text.TextColor3 = Color3.fromRGB(126, 255, 244)
		text.Text = "Welcome"
		script.Parent.switch_on:Play()
		wait(3)
		text.Text = "Loading:\ndoor connection"
		wait(1)
		text.Text = "Loading:\noverheating warning"
		wait(1)
		text.Text = "Loading:\nfire alarm"
		wait(math.random(3,5))
		text.Text = "Loading:\nidle"
		wait(1)
		text.Text = "Loading:\nin movement"
		wait(1)
		text.Text = "Loading:\nlockdown warning"
		wait(1)
		text.Text = "Loading:\ndoor magnematic lock"
		wait(math.random(5,15))
		text.Text = "Reinforcing lock - please wait"
		wait(5)
		text.Text = "Loading:\ncore systems"
		wait(5)
		local broken = math.random(1,5)
		if broken <= 2 then
			text.Text = "An increased heat source has been detected in core:/lockmain/fire/value"
			wait(math.random(1,10))
			status.TextColor3 = Color3.fromRGB(255, 85, 0)
			text.TextColor3 = Color3.fromRGB(255, 85, 0)
			text.Text = "WARNING"
			wait(2)
			text.Text = "OVERHEATING"
			wait(2)
			text.Text = "WARNING"
			wait(2)
			text.Text = "OVERHEATING"
			script.Parent.Parent.fire.Fire.Enabled = true
			script.Parent.Parent.Part.fix.Enabled = true
			script.Parent.fire_alarm.Looped = true
			script.Parent.fire_alarm:Play()
		else
			text.Text = "Idle"
			status.TextColor3 = Color3.fromRGB(255, 255, 255)
			text.TextColor3 = Color3.fromRGB(255, 255, 255)
			script.Parent.Lock.Value = false
		end
		local breakingbad = math.random(1,10)
		if breakingbad == 6 then
			text.Text = "BLAST WARNING\nSEEK SHELTER"
			script.Parent.Parent.fire.Fire.Enabled = true
			script.Parent.fire_alarm:Play()
			status.TextColor3 = Color3.fromRGB(255, 0, 0)
			text.TextColor3 = Color3.fromRGB(255, 0, 0)
			wait(math.random(5,20))
			local expl = Instance.new("Explosion")
			expl.ExplosionType = Enum.ExplosionType.NoCraters
			expl.BlastRadius = 50
			expl.Parent = script.Parent
			game.ServerStorage.Controls.Power.Value = false
			wait(2)
			game.ServerStorage.Controls.Power.Value = true
		end
		while wait(300) do
			broken = math.random(1,5)
			if broken <= 2 then
				print("Monitor broke")
				wait(math.random(1,10))
				script.Parent.Lock.Value = true
				status.TextColor3 = Color3.fromRGB(255, 85, 0)
				text.TextColor3 = Color3.fromRGB(255, 85, 0)
				text.Text = "WARNING"
				wait(2)
				text.Text = "OVERHEATING"
				wait(2)
				text.Text = "WARNING"
				wait(2)
				text.Text = "OVERHEATING"
				script.Parent.Parent.fire.Fire.Enabled = true
				script.Parent.Parent.Part.fix.Enabled = true
				script.Parent.fire_alarm.Looped = true
				script.Parent.fire_alarm:Play()
			else
				print("Monitor intact")
				-- nothing
			end
		end
		
		doorModel.Proximity.Open.Triggered:Connect(function()
			if doorModel.Proximity.Open.ActuallyOpen.Value == false then
				leftOpen:Play()
				rightOpen:Play()
			else
				rightClose:Play()
				leftClose:Play()
			end
		end)
	elseif game:GetService("ServerStorage").Controls.Power.Value == false then
		local surfacegui = script.Parent.SurfaceGui
		local status = surfacegui.STATUS
		local text = surfacegui.TEXT

		status.TextColor3 = Color3.fromRGB(0, 0, 0)
		text.TextColor3 = Color3.fromRGB(0, 0, 0)
		text.Text = "Powered off"
		script.Parent.switch_off:Play()
	end
end)

You can’t pivot a table. You need to pivot the part or the model that you are using for the doors.
Otherwise it won’t work. In the code above you wrote

leftGoalOpen = {}

This becomes an empty table.
Which is causing the error you are having at the moment.

View these documents to learn more.

I realized that after a bit and changed my code, this time the monitor in question starts up but the door doesn’t open when I click the proximity prompt.

local tween = game:GetService("TweenService")
local doorModel = script.Parent.Parent.Parent
doorModel.Left.PrimaryPart = doorModel.Left.Primary
doorModel.Right.PrimaryPart = doorModel.Right.Primary -- delete this if single door
local left = doorModel.Left
local right = doorModel.Right -- delete this if single door

local tiInfo = TweenInfo.new(0.5)
local leftGoalOpen = {}
local leftGoalClose = {}
local rightGoalOpen = {} -- delete this if single door
local rightGoalClose = {} -- delete this if single door

leftGoalOpen.CFrame = left.PrimaryPart.CFrame * CFrame.new(left.PrimaryPart.Size.X, 0, 0)
leftGoalClose.CFrame = left.PrimaryPart.CFrame
local leftOpen = tween:Create(left.PrimaryPart, tiInfo, leftGoalOpen)
local leftClose = tween:Create(left.PrimaryPart, tiInfo, leftGoalClose)

rightGoalOpen.CFrame = right.PrimaryPart.CFrame * CFrame.new(-right.PrimaryPart.Size.X, 0, 0) -- delete this if single door
rightGoalClose.CFrame = right.PrimaryPart.CFrame -- delete this if single door
local rightOpen = tween:Create(right.PrimaryPart, tiInfo, rightGoalOpen) -- delete this if single door
local rightClose = tween:Create(right.PrimaryPart, tiInfo, rightGoalClose) -- delete this if single door

script.Parent.Lock:GetPropertyChangedSignal("Value"):Connect(function()
	if script.Parent.Lock.Value == true then
	doorModel.Proximity.Open.Enabled = false
	if doorModel.Proximity.Open.ActuallyOpen.Value == true then
		doorModel.Proximity.Open.ActuallyOpen.Value = false
		rightGoalClose:Play()
		leftGoalClose:Play()
			doorModel.Left.LeftNeon.Color = Color3.fromRGB(255, 0, 0)
			doorModel.Right.RightNeon.Color = Color3.fromRGB(255, 0, 0) -- delete this if single door
		end
	else
		doorModel.Proximity.Open.Enabled = true
		doorModel.Left.LeftNeon.Color = Color3.fromRGB(255, 255, 255)
		doorModel.Right.RightNeon.Color = Color3.fromRGB(255, 255, 255) -- delete this if single door
	end
end)

game:GetService("ServerStorage").Controls.Power:GetPropertyChangedSignal("Value"):Connect(function()
	if game:GetService("ServerStorage").Controls.Power.Value == true then
		local surfacegui = script.Parent.SurfaceGui
		local status = surfacegui.STATUS
		local text = surfacegui.TEXT
		
		if status.TextColor3 == Color3.fromRGB(126, 255, 244) then return warn("Cannot start while already started") end
		
		status.TextColor3 = Color3.fromRGB(126, 255, 244)
		text.TextColor3 = Color3.fromRGB(126, 255, 244)
		text.Text = "Welcome"
		script.Parent.switch_on:Play()
		wait(3)
		text.Text = "Loading:\ndoor connection"
		wait(1)
		text.Text = "Loading:\noverheating warning"
		wait(1)
		text.Text = "Loading:\nfire alarm"
		wait(math.random(3,5))
		text.Text = "Loading:\nidle"
		wait(1)
		text.Text = "Loading:\nin movement"
		wait(1)
		text.Text = "Loading:\nlockdown warning"
		wait(1)
		text.Text = "Loading:\ndoor magnematic lock"
		wait(math.random(5,15))
		text.Text = "Reinforcing lock - please wait"
		wait(5)
		text.Text = "Loading:\ncore systems"
		wait(5)
		local broken = math.random(1,10)
		if broken <= 3 then
			text.Text = "An increased heat source has been detected in core:/lockmain/fire/value"
			wait(math.random(1,10))
			status.TextColor3 = Color3.fromRGB(255, 85, 0)
			text.TextColor3 = Color3.fromRGB(255, 85, 0)
			text.Text = "WARNING"
			wait(2)
			text.Text = "OVERHEATING"
			wait(2)
			text.Text = "WARNING"
			wait(2)
			text.Text = "OVERHEATING"
			script.Parent.Parent.fire.Fire.Enabled = true
			script.Parent.Parent.Part.fix.Enabled = true
			script.Parent.fire_alarm.Looped = true
			script.Parent.fire_alarm:Play()
		else
			text.Text = "Idle"
			status.TextColor3 = Color3.fromRGB(255, 255, 255)
			text.TextColor3 = Color3.fromRGB(255, 255, 255)
			script.Parent.Lock.Value = false
		end
		local breakingbad = math.random(1,10)
		if breakingbad == 6 then
			text.Text = "BLAST WARNING\nSEEK SHELTER"
			script.Parent.Parent.fire.Fire.Enabled = true
			script.Parent.fire_alarm:Play()
			status.TextColor3 = Color3.fromRGB(255, 0, 0)
			text.TextColor3 = Color3.fromRGB(255, 0, 0)
			wait(math.random(5,20))
			local expl = Instance.new("Explosion")
			expl.ExplosionType = Enum.ExplosionType.NoCraters
			expl.BlastRadius = 50
			expl.Parent = script.Parent
			game.ServerStorage.Controls.Power.Value = false
			wait(2)
			game.ServerStorage.Controls.Power.Value = true
		end
		while wait(300) do
			broken = math.random(1,5)
			if broken <= 2 then
				print("Monitor broke")
				wait(math.random(1,10))
				script.Parent.Lock.Value = true
				status.TextColor3 = Color3.fromRGB(255, 85, 0)
				text.TextColor3 = Color3.fromRGB(255, 85, 0)
				text.Text = "WARNING"
				wait(2)
				text.Text = "OVERHEATING"
				wait(2)
				text.Text = "WARNING"
				wait(2)
				text.Text = "OVERHEATING"
				script.Parent.Parent.fire.Fire.Enabled = true
				script.Parent.Parent.Part.fix.Enabled = true
				script.Parent.fire_alarm.Looped = true
				script.Parent.fire_alarm:Play()
			else
				print("Monitor intact")
				-- nothing
			end
		end
		
		game:GetService("ServerStorage").Controls.Code:GetPropertyChangedSignal("Value"):Connect(function()
			local code = game.ServerStorage.Controls.Code
			if code.Value == "Red" then
				script.Parent.Lock.Value = true
				script.Parent.lockdown_alarm.Looped = true
				script.Parent.lockdown_alarm:Play()
				script.Parent.Parent.monitor.SurfaceGui.TEXT.Text = "SECTOR LOCKDOWN\nSecurity Alert declared\nSECTOR LOCKDOWN"
				script.Parent.Parent.monitor.SurfaceGui.TEXT.TextColor3 = Color3.fromRGB(255, 0, 0)
				script.Parent.Parent.monitor.SurfaceGui.STATUS.TextColor3 = Color3.fromRGB(255, 0, 0)
			end
		end)
		
		doorModel.Proximity.Open.Triggered:Connect(function()
			if doorModel.Proximity.Open.ActuallyOpen.Value == false then
				leftOpen:Play()
				rightOpen:Play()
			else
				rightClose:Play()
				leftClose:Play()
			end
		end)
	elseif game:GetService("ServerStorage").Controls.Power.Value == false then
		local surfacegui = script.Parent.SurfaceGui
		local status = surfacegui.STATUS
		local text = surfacegui.TEXT

		script.Parent.Lock.Value = true
		status.TextColor3 = Color3.fromRGB(0, 0, 0)
		text.TextColor3 = Color3.fromRGB(0, 0, 0)
		text.Text = "Powered off"
		script.Parent.switch_off:Play()
	end
end)

Add some debug prints, seems like something isn’t being executed properly

Where though? Printing every line doesn’t really seem practical

It’s literally for checking what part of the code runs and not, if nothing happens when you click the proximity prompt, print above it, to see if something is happening there. You can also use pcalls, to check for errors.

1 Like

To tween models you should:
Create a CFrame value.
Tween it’s value and just :PivotTo() the model to the CFrame value’s value when it changes.
Example(expect typos since I am on mobile rn):

CFValue = Instance.new("CFrameValue")
CFValue.Changed:Connect(function()
Model:PivoTo(CFValue.Value)
end)
Tween = TweenService:Create(CFValue,tweeninfo,{Value=<insert CFrame here>})
Tween:Play()