Elevator buttons ain't workin'

I’m tryin’ to make it so that a lift with 2 floors will use the same button to go up when it is pressed on the bottom floor and go down when it is pressed on the top floor. I have hooked the elevator to a boolvalue to measure what floor its on and I am using this code:

local TweenService = game:GetService("TweenService")
local Elevator = System.Elevator.ElevatorRR
local UseTween = TweenInfo.new(15, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

local ElevatorUp = TweenService:Create(Elevator, UseTween, {
	Position = System.TopStop.Position
})

local ElevatorDown = TweenService:Create(Elevator, UseTween, {
	Position = System.BottomStop.Position
})

local function Up()
	System.BottomCallButton.Screen.ClickDetector.MaxActivationDistance = 0
	System.Elevator.ElevatorRR.Screen.ClickDetector.MaxActivationDistance = 0
	System.TopCallButton.Screen.ClickDetector.MaxActivationDistance = 0
	System.Elevator.ElevatorRR.Sound.Playing = true
	for index, descendant in pairs(Elevator:GetDescendants()) do
		if descendant:IsA("BasePart") then
			local part = descendant
			local tweenInfo = TweenInfo.new(15, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
			local tween = TweenService:Create(part, tweenInfo, {Position = Vector3.new(descendant.Position.X, descendant.Position.Y +199, descendant.Position.Z)})
			tween:Play()
		end
	end
	ElevatorUp:Play()
	wait(15)
	System.Elevator.ElevatorRR.Sound.Playing = false
	System.Elevator.ElevatorRR.Screen.ClickDetector.MaxActivationDistance = 32
	System.TopCallButton.Screen.ClickDetector.MaxActivationDistance = 32
	System.BottomCallButton.Screen.ClickDetector.MaxActivationDistance = 32
	System.Elevator.ElevatorRR.Screen.Orientation = Vector3.new(0, 0, 90)
	System.Value = true
end

local function Down()
	System.BottomCallButton.Screen.ClickDetector.MaxActivationDistance = 0
	System.Elevator.ElevatorRR.Screen.ClickDetector.MaxActivationDistance = 0
	System.TopCallButton.Screen.ClickDetector.MaxActivationDistance = 0
	System.Elevator.ElevatorRR.Sound.Playing = true
	for index, descendant in pairs(Elevator:GetDescendants()) do
		if descendant:IsA("BasePart") then
			local part = descendant
			local tweenInfo = TweenInfo.new(15, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
			local tween = TweenService:Create(part, tweenInfo, {Position = Vector3.new(descendant.Position.X, descendant.Position.Y -199, descendant.Position.Z)})
			tween:Play()
		end
	end
	ElevatorDown:Play()
	wait(15)
	System.Elevator.ElevatorRR.Sound.Playing = false
	System.Elevator.ElevatorRR.Screen.ClickDetector.MaxActivationDistance = 32
	System.TopCallButton.Screen.ClickDetector.MaxActivationDistance = 32
	System.BottomCallButton.Screen.ClickDetector.MaxActivationDistance = 32
	System.Elevator.ElevatorRR.Screen.Orientation = Vector3.new(0, 180, -90)
	System.Value = false
end

System.BottomCallButton.Screen.ClickDetector.MouseClick:Connect(Down)
System.TopCallButton.Screen.ClickDetector.MouseClick:Connect(Up)

if System.Value == false then
	System.Elevator.ElevatorRR.Screen.ClickDetector.MouseClick:Connect(Up)
end

if System.Value == true then
	System.Elevator.ElevatorRR.Screen.ClickDetector.MouseClick:Connect(Down)
end

What do you mean by not working? Which part?

when i press the button in the elevator it doesnt register the mouseclick at all, no output feed, nothing. those if-then statements in the last 7 lines of code are what controls the elevator button

local function MoveElevator()
    if System.Value == false then
	System.BottomCallButton.Screen.ClickDetector.MaxActivationDistance = 0
	System.Elevator.ElevatorRR.Screen.ClickDetector.MaxActivationDistance = 0
	System.TopCallButton.Screen.ClickDetector.MaxActivationDistance = 0
	System.Elevator.ElevatorRR.Sound.Playing = true
	for index, descendant in pairs(Elevator:GetDescendants()) do
		if descendant:IsA("BasePart") then
			local part = descendant
			local tweenInfo = TweenInfo.new(15, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
			local tween = TweenService:Create(part, tweenInfo, {Position = Vector3.new(descendant.Position.X, descendant.Position.Y +199, descendant.Position.Z)})
			tween:Play()
		end
	end
	ElevatorUp:Play()
	wait(15)
	System.Elevator.ElevatorRR.Sound.Playing = false
	System.Elevator.ElevatorRR.Screen.ClickDetector.MaxActivationDistance = 32
	System.TopCallButton.Screen.ClickDetector.MaxActivationDistance = 32
	System.BottomCallButton.Screen.ClickDetector.MaxActivationDistance = 32
	System.Elevator.ElevatorRR.Screen.Orientation = Vector3.new(0, 0, 90)
	System.Value = true
    elseif System.Value == true then
    System.BottomCallButton.Screen.ClickDetector.MaxActivationDistance = 0
	System.Elevator.ElevatorRR.Screen.ClickDetector.MaxActivationDistance = 0
	System.TopCallButton.Screen.ClickDetector.MaxActivationDistance = 0
	System.Elevator.ElevatorRR.Sound.Playing = true
	for index, descendant in pairs(Elevator:GetDescendants()) do
		if descendant:IsA("BasePart") then
			local part = descendant
			local tweenInfo = TweenInfo.new(15, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
			local tween = TweenService:Create(part, tweenInfo, {Position = Vector3.new(descendant.Position.X, descendant.Position.Y -199, descendant.Position.Z)})
			tween:Play()
		end
	end
	ElevatorDown:Play()
	wait(15)
	System.Elevator.ElevatorRR.Sound.Playing = false
	System.Elevator.ElevatorRR.Screen.ClickDetector.MaxActivationDistance = 32
	System.TopCallButton.Screen.ClickDetector.MaxActivationDistance = 32
	System.BottomCallButton.Screen.ClickDetector.MaxActivationDistance = 32
	System.Elevator.ElevatorRR.Screen.Orientation = Vector3.new(0, 180, -90)
	System.Value = false
end
System.Elevator.ElevatorRR.Screen.ClickDetector.MouseClick:Connect(MoveElevator)
1 Like

Alright I’ve fixed a few of the bugs and found an issue in the naming of things on my part, but this now works and is all fixed and stuff. Thanks!