BaseCamera CoreScript erroring after changing CurrentCamera properties

This is the code I am using to manipulate the camera. Honestly wasn’t sure to put this as a bug report or general help, but considering it appears I am using Camera as normal, and that a core script is managing to error, I assume it may be a bug in the core script.

if Value then
		CurrentCamera.CameraType = Enum.CameraType.Scriptable
		
		TweenService:Create(CurrentCamera, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {
			CFrame = Folder.OverCam.CFrame
		}):Play()
		
		task.wait(1)
	else
		CurrentCamera.CameraType = Enum.CameraType.Custom
		CurrentCamera.CameraSubject = Humanoid
	end	

This is the error that appears when the if statement is evaluated as not Value. In other words, when these lines run:

CurrentCamera.CameraType = Enum.CameraType.Custom
CurrentCamera.CameraSubject = Humanoid

The boxed line is the line that is erroring.

It’s also worth noting that this does not happen every time. Seems to be occasional.

Forum moderators if this is just an issue on my part, feel free to migrate this post to the respective category. However, given its nature, I think it might be a bug. Apologies if I am wrong though.

1 Like

After investigating and putting some debug prints shown below:

It warned this when the math.clamp errored:

It seems as if currPitchAngle is nan, so when it is added to -MAX_Y or -MIN_Y, it becomes nan. currPitchAngle becomes nan because math.asin (arcsin) only has a domain of [-1,1]. Since currLookVector.Y is slightly under -1 (by less than 6 decimal points, -1.0000001192092896), it will spit out nan.

Here is a video of the bug happening:

For now, while this is being looked at, I simply just added a clamp to the currLookVector.Y so that it always fits in the range of arcsin. With this way, my game’s flow won’t be disrupted by this very occasional error, just a bandaid fix. Very weird error though.


Let me know if I need to provide any more information.