I am using CFrame and Vector 3 to create a Sliding Door made of Unions.

Here's the Hierarchy.

This is the door before the door opens.

Then this happens as it's moving.

And it just stays like that.

This is the script:

local Door1 = script.Parent.Parent.Door1
local Door2 = script.Parent.Parent.Door2
local State = script.Parent.Parent.State

script.Parent.ClickDetector.MouseClick:connect(function()
	if State.Value == 0 then
		State.Value = 1
		for i = 1, 30 do
			Door1.CFrame = CFrame.new(Door1.Position + Vector3.new(.1, 0, 0))
			Door2.CFrame = CFrame.new(Door2.Position - Vector3.new(.1, 0, 0))
			wait()
		end	
		wait(2)
		for i = 1, 30 do
			Door1.CFrame = CFrame.new(Door1.Position - Vector3.new(.1, 0, 0))
			Door2.CFrame = CFrame.new(Door2.Position + Vector3.new(.1, 0, 0))
			wait()
		end
		State.Value = 0
	end
end)

If you could give me an explanation as to why it rotates that way, it'd be much appreciated. Thanks!

1 comment

1

Make sure the door is anchored, unanchored parts will cause that problem, to fix it with unanchored parts, you would have to use welds