Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why Does this Part Rotate Oddly?

Asked by 9 years ago

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
Make sure the door is anchored, unanchored parts will cause that problem, to fix it with unanchored parts, you would have to use welds FutureWebsiteOwner 270 — 9y

Answer this question