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

Elevator never stops?

Asked by 8 years ago

So, basically, in this block of code, I want to make an elevator to move on the Y axis until the base part's Y axis reaches 10 (exactly), and yet the elevator continues to move upward, and not stopping at 10.

if Elevator.InUse.Value == false then
    Elevator.InUse.Value = true
    while Elevator.Base.CFrame.y ~= 10 do --Problem area
        for _,v in pairs(Elevator:GetChildren()) do
            if v.ClassName == "Part" then
                v.CFrame = v.CFrame * CFrame.new(0,0.1,0)
            end
        end
        for _,v in pairs(script.Parent.Parent:GetChildren()) do
            if v.ClassName == "Part" then
                v.CFrame = v.CFrame + Vector3.new(0,0.1,0)
            end
        end
        Elevator.EleDoors.EleDoorLeft.CFrame = Elevator.EleDoors.EleDoorLeft.CFrame * CFrame.new(0,0.1,0)
        Elevator.EleDoors.EleDoorRight.CFrame = Elevator.EleDoors.EleDoorRight.CFrame * CFrame.new(0,0.1,0)
        wait(0.02)
    end
    Elevator.InUse.Value = false
end

Is there a way to change "while Elevator.Base.CFrame.y ~= 10 do" so that the Base part's position will determine how far the elevator moves upward?

1 answer

Log in to vote
0
Answered by
funyun 958 Moderation Voter
8 years ago

Does it have to be at exactly 10? Would you settle for, maybe, a tiny bit more than 10?

while Elevator.Base.CFrame.y <= 10 do
0
Alright, thanks! I made it "while Elevator.Base.CFrame.y <= 9.8 do", thanks! Glueable 20 — 8y
Ad

Answer this question