i’m trying to make a camera script it has a table of different very specific cframes for different cameraparts, but i keep getting the same error
i’m not understanding the error and i’ve been researching for quite a while before coming here i would really appreciate help
(i apologize if my explanation is poor i dont post here very often)
-- variables
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local reps = game:GetService("ReplicatedStorage")
local char = player.Character or player.CharacterAdded:Wait()
char:WaitForChild("HumanoidRootPart")
-- setting camera
camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 65
-- camera parts
local camParts = {
tutorialcamPart = workspace.tutorial:WaitForChild("tutorialCameraPart"),
notosofficecamPart = workspace.chapter1.notosoffice:WaitForChild("desk"),
}
-- cframes of the camera positions
local camCFrames =
{
[1] = {CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0, 12, 12) * CFrame.Angles(math.rad(-45), 0, 0)},
[2] = {CFrame.new(camParts.tutorialcamPart.Position) * CFrame.new(0, 12, 12) * CFrame.Angles(math.rad(-45), 0, 0)},
[3] = {CFrame.new(camParts.notosofficecamPart.Position) * CFrame.new(3, 2, 4) * CFrame.Angles(math.rad(-9), math.rad(25), math.rad(2))}
}
-- variable for the camera pos in use
local camInUse = false
-- function to change the camera pos in use
local function changeCam(cam)
camInUse = camCFrames[cam]
end
-- using the camera
game:GetService("RunService").RenderStepped:Connect(function()
camera.CFrame = camInUse -- the line the error is on
end)
changeCam(1) -- change the camera