Hey, so I’m trying to make an exit button, but I’m not very good with “elseif” and I don’t know how to use it. Mind helping me? Also, please don’t judge, I’m trying my best.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local movingEvent = ReplicatedStorage:WaitForChild("MovingElevator")
local elevatorEvent = ReplicatedStorage:WaitForChild("Elevator")
local elevatorEvent2 = ReplicatedStorage:WaitForChild("Elevator2")
local elevatorEvent3 = ReplicatedStorage:WaitForChild("Elevator3")
local elevatorEvent4 = ReplicatedStorage:WaitForChild("Elevator4")
local elevatorEvent5 = ReplicatedStorage:WaitForChild("Elevator5")
local gui = script.Parent
local exitBtn = gui.Exit
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local Values = player:FindFirstChild("Values")
movingEvent.OnClientEvent:Connect(function()
exitBtn.Visible = false
end)
elevatorEvent.OnClientEvent:Connect(function(elevator)
exitBtn.Visible = true
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = elevator.Camera.CFrame
end)
local eventFolder = game.ReplicatedStorage.EventFolder -- This is the folder holding the events
exitBtn.Activated.Connect(function()
exitBtn.Visible = false
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = player.Character.Humanoid
-- Fire the corresponding elevator number's event
eventFolder["elevatorEvent"..Values.ElevatorNumber.Value]:FireServer()
-- If the above line does not work, try the line below instead:
--eventFolder:FindFirstChild("elevatorEvent"..Values.ElevatorNumber.Value):FireServer()
-- Use tasks for efficiency
task.defer(function()
task.wait(0.1)
Values.ElevatorNumber.Value = 0
end)
end)