I’m not the best at making titles.
-
What do you want to achieve? I want to achieve a camera switching system (<-- for the first time ever) (NOT a spectate GUI) where it goes around the 4 cameras in
workspace.Camerasfolder. Basically, if a player presses the next camera or the previous camera button, it would move the player’s camera to the next or previous camera & change the label (for example, camera A, Text: “Camera #1” to Camera B, Text: “Camera #2” & so on). It’s like choosing a plot in bloxburg, it’d switch the cameras to show the plot you’re choosing. -
What is the issue? Before I coded stuff for the camera, the label did work, including the current camera label #1-#4 limit. Now that I have the camera code, the 1-4 limit breaks & you can go under 1 or above 4 which breaks the code & outputs errors like “Camera5 not found” or something like that or… “Camera -68 not found”.
-
What solutions have you tried so far? I have tried changing the
CurrentCameraNumbervariable into aNumberValue, did not help at all, including theCameraSubject. (I have put the camera type stuff in a different script so that’s why the repeat wait() loop for the camera type isn’t in the script (aka. the script I’m having problems on) that’s handling the changing of cameras)
Video (to explain my idea more): (deleted because I thought streamable would keep your videos if you’re visitor/guest (basically, unregistered user))
Structure:

Code (handling camera changes) (Excluded hover animations & irrelevant variables):
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
local cameras = workspace:WaitForChild("Cameras")
local camera1 = cameras:WaitForChild("Camera1")
local button1 = script.Parent:WaitForChild("NextButton")
local button2 = script.Parent:WaitForChild("PreviousButton")
local label1 = script.Parent:WaitForChild("CameraLabel")
local currentCameraNumber = 1
local maximumCameraNumber = 4
button1.MouseButton1Click:Connect(function()
currentCameraNumber = currentCameraNumber + 1
label1.Text = "Camera #" .. currentCameraNumber
camera.CFrame = cameras["Camera" .. currentCameraNumber].CFrame
if currentCameraNumber > maximumCameraNumber then
currentCameraNumber = 1
label1.Text = "Camera #" .. currentCameraNumber
camera.CFrame = cameras["Camera" .. currentCameraNumber].CFrame
end
end)
button2.MouseButton1Click:Connect(function()
currentCameraNumber = currentCameraNumber - 1
label1.Text = "Camera #" .. currentCameraNumber
camera.CFrame = cameras["Camera" .. currentCameraNumber].CFrame
if currentCameraNumber < 1 then
currentCameraNumber = maximumCameraNumber
label1.Text = "Camera #" .. currentCameraNumber
camera.CFrame = cameras["Camera" .. currentCameraNumber].CFrame
end
end)
