Camera CFrame Behaving Strangely

Hey there,

The script below is moving my camera, but it isn’t putting it exactly within the part that I want it to (camera1). All of the print statements are displayed in the output.

function changeCamera()
	
	local camera = workspace.CurrentCamera

	wait()

	print('test')
	
	camera.CameraType = Enum.CameraType.Fixed
	
	print('test2')
	
	camera.CFrame = game.Workspace.House.Cameras.Camera1.CFrame
	
	print('test3')

end
game.ReplicatedStorage.ViewSecurity.OnClientEvent:Connect(changeCamera)

As you can see above, the camera is locking, but not directly within the part.

Any help is appreciated :slight_smile:

1 Like

Try putting a wait between the fixed and cframe code

Is there any offset on the camera? The video won’t load for me for some reason so I can’t really see properly

Whenever I do that, I use runservice to keep the cframe there continuously until otherwise stated.

Doesn’t work :frowning:

The camera is fixating on a point that is facing way too far ahead of the part.

The part is 1x1x1.5

i finally got the video to load, looking at it now

Can you check that it actually is by making it move a part there instead? From my experience that looks right.

I believe that rather than using Enum.CameraType.Fixed, you should use Enum.CameraType.Scriptable for this purpose. So, instead of using:

function changeCamera()
	local camera = workspace.CurrentCamera
	wait()
	print('test')
	camera.CameraType = Enum.CameraType.Fixed
	print('test2')
	camera.CFrame = game.Workspace.House.Cameras.Camera1.CFrame
	print('test3')
end
game.ReplicatedStorage.ViewSecurity.OnClientEvent:Connect(changeCamera)

You should use:

function changeCamera()
	local camera = workspace.CurrentCamera
	task.wait()
	print('test')
	camera.CameraType = Enum.CameraType.Scriptable
	print('test2')
	camera.CFrame = game.Workspace.House.Cameras.Camera1.CFrame
	print('test3')
end
game.ReplicatedStorage.ViewSecurity.OnClientEvent:Connect(changeCamera)
2 Likes

try setting the camera type to scriptable instead that’s how I do it and that always works

Alright, I’ll look into it later today, thanks to all who have offered their help.

Edit: Thanks @usr_updated!