Help with Elevator

Hi! I’m a beginner scripter who wants to make an elevator for my game. I’ve tried a few tutorials, but either A, the script just doesn’t work, or B, when it does work, the elevator floor part turns on an axis. I want to get an elevator that is reliable and is button activated. I have already written some basic code for the building blocks of the elevator, now I just need someone to help me out with the actual elevator part.

Heres my code:

local elevator = script.Parent

local upbutton = game.Workspace.ElevatorEntrance.UpButton
local downbutton = game.Workspace.ElevatorEntrance.DownButton

local cdup = upbutton.ClickDetector
local cddown = downbutton.ClickDetector

local up = Vector3.new(-37.964, 53.757, 48.704)
local down = Vector3.new(-37.964, 0.73, 48.704)

function goingUp()
	print("Goin' Up!")

end

function goingDown()
	print("Goin' Down!")

end

cdup.MouseClick:Connect(goingUp)
cddown.MouseClick:Connect(goingDown)

Thank you!

is the elevator a model? or just a single part

Hi! The elevator is just a single cylinder part that would go up and down at the press of a button.

here is the code for the function

local wait = task.wait
local speed = 8 /50 -- How many seconds from start to end
-- example: 8 /50 takes 8 seconds, 20 /50 takes 20 seconds

function goingUp()
	print("Goin' Up!")
	for t = 1, 50 do
		elevator.Position = down:Lerp(up,t/50))
		wait(speed/50)
	end
end

function goingDown()
	print("Goin' Down!")
	for t = 1, 50 do
		elevator.Position = up:Lerp(down,t/50))
		wait(speed/50)
	end
end

you can modify the speed to what you want

1 Like