I would like to have the doors push out, and slide to not block the doorway. I had this achieved on one side of the build, but on the other it opens facing the wrong way.
What it ends up looking like (Ignore that left door isn’t open)
I have tried looking around the DevForum and looked the issue up on the Developer Hub, but could not find anything for that. I’m also not very experienced with CFrame so I have no idea what to do.
This is the script I am currently using.
for i = 1,35 do
script.Parent.Parent.Door13.CFrame = CFrame.new(script.Parent.Parent.Door13.Position) + Vector3.new(-0.015,0,0)
wait()
end
game.Workspace.Cylinder1.Size = Vector3.new(1, 0.25, 0.25)
for i = 1,50 do
script.Parent.Parent.Door13.CFrame = CFrame.new(script.Parent.Parent.Door13.Position) + Vector3.new(0,0,0.0625)
wait()
I suspect the issue is the way in which you’re updating the CFrame of Door13.
Try changing this:
for i = 1,35 do
script.Parent.Parent.Door13.CFrame = CFrame.new(script.Parent.Parent.Door13.Position) + Vector3.new(-0.015,0,0)
wait()
end
To this:
for i = 1,35 do
script.Parent.Parent.Door13.CFrame = script.Parent.Parent.Door13.CFrame + Vector3.new(-0.015,0,0)
wait()
end
The reason is when you call CFrame.new(Vector3 position) Roblox will create a CFrame with the provided position but the rotation will be set to a default rotation as you haven’t provided it in CFrame.new(). That’s why your door is facing the wrong direction.
I’d personally use TweenService for these scenarios, as they’re stable and I use them all the time when moving objects. For your situation, it’d look like:
local ts = game:GetService("TweenService") -- getting the service
local door = script.Parent.Parent.Door13
local move = ts:Create(door, TweenInfo.new(.35, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, false, 0), {Position = door.Position + Vector3.new(-0.015, 0, 0)})
move:Play()
game.Workspace.Cylinder1.Size = Vector3.new(1, 0.25, 0.25)
move = ts:Create(door, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, false, 0), {Position = door.Position + Vector3.new(0, 0, .625)})
move:Play()
I strongly recommend creating tweens, as they’re simple to use and there’s no reason to get overwhelmed of getting a CFrame wrong.