Hey, I’ve been trying to script an elevator for the past few hours but one of my functions for the elevator doors keeps breaking, I’ve attempting to change the way the variables are set up a few different times and I’m just stuck. When the function is called, doort2 moves its width in the correct amount like it is supposed too, however immediately after doort1 ends out moving in a direction indefinitely without the loop breaking. How should I go about fixing this? Here is the function:
local function OpenDoorT()
local moved = 0
repeat
doort2.CFrame = doort2.CFrame:ToWorldSpace(CFrame.new(0,0,-0.1))
moved = moved + 0.1
wait()
until moved == 2.8
local moved2 = 0
wait(0.5)
while moved2 <= 3.3 do
doort2.CFrame = doort2.CFrame:ToWorldSpace(CFrame.new(0,0,-0.1))
doort1.CFrame = doort1.CFrame:ToWorldSpace(CFrame.new(0,0,-0.1))
moved2 = moved2 + 0.1
wait()
end
moved2 = 0
end