I know you can make button elevators, but is it possible to make an elevator that goes up until it hits a part, and goes down until it hits another and continues that cycle?
--I realize this would have something to do with a while true do
loop, but what would the script look like? (I am sorry I am fairly new to scripting in RBX.Lua as a whole but want to create an elevator that will just contiguously loop up and down for a place.
Oh, sorry I didn't read your question so I made a bad script :P
el = Workspace.ElevatorPart -- Assume these blocks are here... top = Workspace.Top bottom = Workspace.Bottom up = true down = false bodypos = Instance.new("BodyPosition", el) bodypos.maxForce = Vector3.new(math.huge,math.huge,math.huge) bodypos.position = el.Position bodygyro = Instance.new("BodyGyro", el) waiting = false -- you can add waiting el.Touched:connect( function(hit) if hit == top then -- You can add waiting by removing all the comments before waiting in the function below --waiting = true down = true up = false --wait(2) --waiting = false elseif hit == bottom then --waiting = true up = true down = false --wait(2) --waiting = false end end) game:GetService("RunService").RenderStepped:connect( function() if up and not waiting then bodypos.position = bodypos.position+Vector3.new(0,0.1,0) elseif down and not waiting then bodypos.position = bodypos.position-Vector3.new(0,0.1,0) end end)
Hope this script helped :)