I'm making a security camera script and the output is printing this: Players.NiroTurtle.PlayerGui.CameraGui.LeftButton.CamScript:11: attempt to index field '?' (a nil value) I'm trying to make it so when you click the arrow, the next thingy in the table will be the camera's new CFrame. Here's the code. Please help!!!!!
local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
local currentCam = 1
local button = script.Parent
local camFolder = game.Workspace.Cameras
local cameras = {camFolder.Camera1.SecCamPart, camFolder.Camera2.SecCamPart, camFolder.Camera3.SecCamPart, camFolder.Camera4.SecCamPart, camFolder.Camera5.SecCamPart, camFolder.Camera6.SecCamPart}
button.MouseButton1Click:Connect(function()
if button.Text == "<" then
if currentCam - 1 <= 0 then
cam.CFrame = cameras[6].CFrame
cam.CameraType = Enum.CameraType.Scriptable
plr.CameraMode = "LockFirstPerson"
else
cam.CFrame = cameras[currentCam - 1].CFrame
cam.CameraType = Enum.CameraType.Scriptable
plr.CameraMode = "LockFirstPerson"
end
else
if currentCam + 1 >= 7 then
cam.CFrame = cameras[1].CFrame
cam.CameraType = Enum.CameraType.Scriptable
plr.CameraMode = "LockFirstPerson"
else
cam.CFrame = cameras[currentCam + 1].CFrame
cam.CameraType = Enum.CameraType.Scriptable
plr.CameraMode = "LockFirstPerson"
end
end
end)
