Hello, I am currently having trouble with making a garage-like door. I am attempting to make the panels follow two separate attachments and then make the position of the panel where the middle point is. I am trying to use CFrame.lookat() and CFrame.new() (CFrame.new for the positions makes the bug last longer.) but the panel seems to have its orientation changed weirdly by the lookAt (Y orientation being 0, 90 when it’s currently bugging, and 180 when it returns to the normal path). What could be causing this and what could I do to fix this or what method to use to do this? Thanks.
Here’s what’s happening:
Here’s my code:
local TS = game:GetService("TweenService")
local Garage = script.Parent
local reachedEnd = false
for i, panel: part in pairs(Garage:GetChildren()) do
if panel.Name:find("Panel") then
task.spawn(function()
local num = string.split(panel.Name," ")[2]
local tweening = false
local tween
local finished = false
-- ...
local group = Garage:FindFirstChild("Panel"..num.."Group").Union
while true do
local posA = group.Lower.WorldPosition
local posB = group.Higher.WorldPosition
task.wait(0.01)
if panel.Top.WorldPosition.Y < group.MiddleGuide.WorldPosition.Y and (not tweening) then
panel.Position = panel.Position+Vector3.new(0,0.02,0)
elseif ((panel.Top.WorldPosition.Y >= group.MiddleGuide.WorldPosition.Y) or tweening) and not finished then
group.Lower.Visible = true
group.Middle.Visible = true
group.Higher.Visible = true
panel.CFrame = CFrame.lookAt(posA,posB) -- Problem
group.Middle.WorldPosition = (posA+posB)/2
panel.Position = group.Middle.WorldPosition+Vector3.new(panel.Size.X/2,0,0)
if not tweening then
tweening = true
tween = TS:Create(group.Lower, TweenInfo.new(1,Enum.EasingStyle.Linear),{WorldPosition=group.MiddleGuide.WorldPosition})
tween:Play()
task.spawn(function()
tween.Completed:Connect(function()
finished = true
end)
end)
TS:Create(group.Higher, TweenInfo.new(1,Enum.EasingStyle.Linear),{WorldPosition=group.HigherGuide.WorldPosition}):Play()
end
end
-- ...
end
end)
end
end