Buzzy

Loading...

Buzzy

Register

Roblox Studio Tutorials - August 8, 2021

How to Make an Elevator on Roblox Studio

1

Buzzy Beth

@buzzygamesbeth

  • today i’ll be showing you how to make an elevator in roblox studio
  • as you can see i’ve already got a part and attach a script to it and we’re going to take a look at that script
  • so we have our two variable a, a value and a direction and then we have our while loop so while true
  • we’re going to update the position and if it’s above a certain height then we’re going to reverse the direction if it’s below a certain height we’re going to make it the other way we have this weight here
  • something to note is these two values are going to change depending on your height. my starting height right here is three which is the lower bound for here and i don’t want it to go higher than 10
  • if you want to go faster but it will be less smooth then you can change this value right here
  • then when we hit play we will see that our elevator works just as it did in the opening!
local val = 0.2
local direction = 1

while true do
	script.Parent.Position = script.Parent.Position + Vector3.new(0, val*direction, 0)
	if script.Parent.Position.Y > 10 then --upper bound number
		direction = -1
	end
	
	if script.Parent.Position.Y < 3 then --lower bound number
		direction = 1
		
	end
	
	wait(0.05)
	
end