Bring camera back to player view?

I have a camera pointing at a part, however, I can’t get it back to player view:

repeat
    wait();
    Camera.CameraType = Enum.CameraType.Scriptable;
until Camera.CameraType == Enum.CameraType.Scriptable;

Camera.CFrame = workspace.Part.CFrame;

And in my function to stop the camera (go back to normal view):

repeat
    wait();
    Camera.CameraType = Enum.CameraType.Custom;
until Camera.CameraType == Enum.CameraType.Custom;
1 Like

Couldn’t you just reset the CameraType back to Custom:

Camera.CameraType = Enum.CameraType.Custom

That’s what I did? Check the second chunk of code. O_o

Oop sorry, Didn’t notice that!

Maybe you could try setting the CFrame, CameraSubject, and CameraFocus too

local CameraCFrame = Camera.CFrame -- This variable needs to be set before changing the CFrame

Camera.CameraSubject = Humanoid -- Define the Player's Humanoid
Camera.Focus = HumanoidRootPart.CFrame -- Define the Player's HumanoidRootPart
Camera.CFrame = CameraCFrame
1 Like

Hello, ILikeTurtlesUwU. The functions you provided could work, but we need to see where and how you are calling them to fully resolve your issue.

1 Like

Those two functions are the only places I’m calling the Camera. :confused:

I believe you misunderstood my question. Functions can be called throughout the code. For example:

function enableCustomCam()
	repeat
		wait();
		Camera.CameraType = Enum.CameraType.Scriptable;
	until Camera.CameraType == Enum.CameraType.Scriptable;

	Camera.CFrame = workspace.Part.CFrame;
end

function disableCustomCam()
	repeat
		wait();
		Camera.CameraType = Enum.CameraType.Custom;
	until Camera.CameraType == Enum.CameraType.Custom;
end

while wait() do
	if menuCam then
		enableCustomCam()
	else
		disableCustomCam()
	end
end
2 Likes

It could be because you’re using a server script to change the camera back to the player. Each player has their own camera, so you can’t edit it from a server script.

1 Like

Consider defining functions locally and using task.wait() (1/60th of a frame delay) instead of wait() (1/30th of a frame delay). Alternatively you can use RunService.RenderStepped:Wait() (which also yields for 1/60th of a frame) which is purposed for camera-related scripting.