Tweening camera to look at a part makes screen black

local FocusInfo = TweenInfo.new(1, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
local Focus = tweenservice:Create(cam, FocusInfo, {CFrame = screen.CFrame})

this tween is just making my camera black and idk why

screen is a part and cam is the currentcamera

It could be that the camera is going inside the part?

Since your technically tweening the cam inside the part, also is the camera set to scriptable?

well in that case how do i make the camera just look at it?

Usually when I’m using the camera object for something like a security cam I would just maybe tween the cam to a transparent part that looking at the screen, though this may not be the most reliable way as it can involve testing, another way you could use is to just subtract some values or add perhaps for, but it depends on which way your “screen” is, you could just change the X value.
Example:

local Focus = tweenservice:Create(cam, FocusInfo, {CFrame = (screen.CFrame - Vector3.new(0, 0, -5))})

im not trying to move the position of the camera only its roation to look at a part

Oh but by using the CFrame of the screen frame, your moving the camera. I do have something that could rotate it by using CFrame however:

local Focus = tweenservice:Create(cam, FocusInfo, {CFrame = (CFrame.LookAt(cam.CFrame.Position, screen.Position))})

So what this does is that it keeps the camera is place but tweens or “rotates” it to look at the screen from that position.

i just get this:
“attempt to call a nil value”

Does it tell you which line specifically and which argument its appearing as an error?

comes from the line that makes the tween

Give me a second to analysis what the problem might be, though it would help to know which argument is causing it.

It would help to know more of the script as I could see how the variables are being defined to what values, I believe it could be either a typo, or in fact a potential issue could BE that the object hasn’t loaded yet.

Does this script run directly as when the player joins the game?

im going to try only making the tween when it needs to be used, by the time u need to use it everything would be loaded

just tried that and its the same error.
The cam is the game.workspace.currentcamera and the screen is just a part
The script is a local script

That could be the issue, as if you make the script get all of these objects and they may not have loaded yet it can cause values to be undefined or “nil”. I would maybe use: task.wait().

I would maybe make the script maybe run after task.wait() or wait(5)

it aldready does that thought so idk what the issue is

Does it do it before the screen is defined or camera?