What I am trying to achieve is that when I click on a button the perspective of the camera changes, but I get this error
Here is my script
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local item = script.Parent.Parent:WaitForChild("CameraToSee")
local maximum = script.Parent.Parent.MaxCameras
local minimum = script.Parent.Parent.MinCameras
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Tween = TweenInfo.new(
0,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In,
0
)
script.Parent.MouseButton1Click:Connect(function()
if item.Value > minimum.Value then
item.Value = item.Value - 1
local CameraToViewGoal = game.Workspace.Cameras:WaitForChild("Camera"..item.Value)
local CFrameOfCamera = CameraToViewGoal.CFrame
local AnimationCamera = TweenService:Create(camera, Tween, CFrameOfCamera)
camera.CameraType = Enum.CameraType.Scriptable
AnimationCamera:Play()
elseif item.Value == minimum.Value then
item.Value = maximum.Value
local CameraToViewGoal = game.Workspace.Cameras:WaitForChild("Camera"..item.Value)
local CFrameOfCamera = CameraToViewGoal.CFrame
local AnimationCamera = TweenService:Create(camera, Tween, CFrameOfCamera)
camera.CameraType = Enum.CameraType.Scriptable
AnimationCamera:Play()
end
end)
Screenshots: