Trying to make a simple sliding door tween, but I want to instead have the parts just resize themselves to split down the middle and fit to the edge. I don’t want to just slide them to the side, but for now, this is what I have →
https://gyazo.com/4310ad7c36f779fe26fe9f006974cde9
Essential Question: How can I make the doors split down the middle, and resize instead of just moving CFrame?
Code →
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1)
local PartA = script.Parent.Parent.PartA
local PartB = script.Parent.Parent.PartB
--[[ DOOR ]]--
local leftGoalOpen = {}
local leftGoalClose = {}
leftGoalOpen.CFrame = PartA.CFrame * CFrame.new(PartA.Size.X, 0,0)
leftGoalClose.CFrame = PartA.CFrame
local leftTweenOpen = TweenService:Create(PartA, tweenInfo, leftGoalOpen)
local leftTweenClose = TweenService:Create(PartA, tweenInfo, leftGoalClose)
local rightGoalOpen = {}
local rightGoalClose = {}
rightGoalOpen.CFrame = PartB.CFrame * CFrame.new(-PartB.Size.X, 0,0)
rightGoalClose.CFrame = PartB.CFrame
local rightTweenOpen = TweenService:Create(PartB, tweenInfo, rightGoalOpen)
local rightTweenClose = TweenService:Create(PartB, tweenInfo, rightGoalClose)
local sound = script.Parent.Sound
--[[ FUNCTION ]]--
local DoorOpening = false
script.Parent.ProximityPrompt.Triggered:Connect(function()
if DoorOpening == false then
rightTweenOpen:Play()
leftTweenOpen:Play()
sound:Play()
wait(2)
script.Parent.ProximityPrompt.ObjectText = "Close"
DoorOpening = true
else
rightTweenClose:Play()
leftTweenClose:Play()
sound:Play()
wait(2)
script.Parent.ProximityPrompt.ObjectText = "Open"
DoorOpening = false
end
end)