Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Elevator never stops?

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

✓ Accepted answer

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

1 comment

0

Alright, thanks! I made it "while Elevator.Base.CFrame.y <= 9.8 do", thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.