I’m currently trying to get my head round coding a realistic automatic sliding door, essentially what im trying to do is incorporate CFrames with a tween. I’m using CFrames because of the lookvectors. However, I’m not quite sure how to do this. Any help is appreciated.
My code (so far):
-- Doors
local left = script.Parent.Parent.Left.Primary
local right = script.Parent.Parent.Right.Primary
-- Services
local TweenService = game:GetService("TweenService")
-- Config
local Config = require(script.Parent.Parent.Configuration)
-- Tablet position.
local Tablets = script.Parent.Parent.Tablets
-- UI Buttons
local Lock = Tablets:GetDescendants("Locked")
local ForceOpen = Tablets:GetDescendants("Force Open")
local ForceClose = Tablets:GetDescendants("Force Close")
local FireMode = Tablets:GetDescendants("Fire Mode")
local Hold = Tablets:GetDescendants("Hold")
-- Player Detection
local PlayerDetection = script.Parent.Parent.PlayerDetection
local DetectPart = PlayerDetection:GetDescendants()
-- Tweens
local TweenLInfo = TweenInfo.new(
5, --Time
Enum.EasingStyle.Linear, -- Style of door open animation
Enum.EasingDirection.In, -- Direction of easing.
-1, -- Repeat count.
false, -- Will it reverse?
0 -- The delay time.
)
-- open look vectors
local leftopen = {Position = left.CFrame == left.CFrame + (-left.CFrame.lookVector*14)}
local rightopen = {Position = right.CFrame == right.CFrame + (right.CFrame.lookVector*14)}
-- close look vectors
local leftclose = {Position = left.CFrame == left.CFrame + (left.CFrame.lookVector*14)}
local rightclose = {Position = right.CFrame == right.CFrame + (-right.CFrame.lookVector*14)}
local tweenLopen = TweenService:Create(left, TweenLInfo, leftopen)
local tweenLclose = TweenService:Create(left, TweenLInfo, leftclose)
local TweenRInfo = TweenInfo.new(
5, --Time
Enum.EasingStyle.Linear, -- Style of door open animation
Enum.EasingDirection.In, -- Direction of easing.
-1, -- Repeat count.
false, -- Will it reverse?
0 -- The delay time.
)
local tweenRopen = TweenService:Create(right, TweenRInfo, rightopen)
local tweenRclose = TweenService:Create(right, TweenRInfo, rightclose)
local UI = TweenInfo.new(
0.3, --Time
Enum.EasingStyle.Linear, -- Style of hover interact animation
Enum.EasingDirection.In, -- Direction of easing.
-1, -- Repeat count.
false, -- Will it reverse?
0 -- The delay time.
)
tweenLopen:Play()