Trouble making a Sliding Door

Hello, i’ve recently started Scripting and while I was following a Tutorial from AlvinBlox to make a sliding door, However i encountered an error and i have tried all in my power to fix it. So I’d like to know if you guys could help me

Code:

local TweenService = game:GetService(“TweenService”)

local door1 = game.Workspace[“S.Door”].Door1

local door2 = game.Workspace[“S.Door”].Door2

local TweeningInformation = TweenInfo.new{

.5,

Enum.EasingStyle.Linear,

Enum.EasingDirection.Out,

0,

false,

0

}

local door1close = (CFrame = CFrame.new(-68.06, 5.25, 19.753))

local door1open = (CFrame = CFrame.new (-76.06, 5.25, 19.753))

local door2open = (CFrame = CFrame.new(-52.122, 5.25, 19.753))

local door2close = (CFrame = CFrame.new(-59.997, 5.25, 19.753))

local tween1open = TweenService:Create(door1,TweeningInformation,door1open)

local tween1close = TweenService:Create(door1,TweeningInformation,door1close)

local tween2open = TweenService:Create(door1,TweeningInformation,door2open)

local tween2close = TweenService:Create(door1,TweeningInformation,door2close)

script.Parent[“Detector 1”].Touched.Connect(function(hit)

tween1open:Play()

tween2open:Play()

wait(5)

tween1close:Play()

tween2close:Play()

end)

script.Parent[“Detector 2”].Touched.Connect(function(hit)

tween1open:Play()

tween2open:Play()

wait(5)

tween1close:Play()

tween2close:Play()

end)

The Problem:
image

Thanks in advanced

1 Like

The error is on this line, and the ones following

local door1close = (CFrame = CFrame.new(-68.06, 5.25, 19.753))

it should be {} not (). As {} is an array and () is nothing on it’s own.

local door1close = {CFrame = CFrame.new(-68.06, 5.25, 19.753)}
1 Like

Try this, hope it is what you needed!! :+1:

Adding to MrLonely1221’s reply, you shouldn’t set the position in world coordinates, as it will not work once you move or rotate the doors.
Try this instead

local door1close = {CFrame =  door1.CFrame}
local door1open = {CFrame = door1.CFrame * CFrame.new(-1, 0, 0)}
local door2close = {CFrame =  door2.CFrame}
local door2open = {CFrame = door2.CFrame * CFrame.new(-1, 0, 0)}
1 Like

Your code here will just constantly make it move. As door1.CFrame and door2.CFrame will just reference the current position, it would be a good idea to save the position it’s at as a variable at the top so that it doesn’t just stay in one position and keep scooting back.

local d1CFrame = door1.CFrame;
local d2CFrame = door2.CFrame;

local door1close = {CFrame =  d1CFrame}
local door1open = {CFrame = d1CFrame * CFrame.new(-1, 0, 0)}
local door2close = {CFrame =  d2CFrame}
local door2open = {CFrame = d2CFrame * CFrame.new(-1, 0, 0)}
1 Like