Camera doesn't work in the right position

Working on a commision my problem is that the camera doesn’t go on the right position.

This is where it’s supposed to be, when I use the CameraType “Scriptable”, it shows the right location, but I can rotate the camera around, which I do not want.

So then I’m using Fixed instead, and that goes then, on the wrong position for some reason.

This is the code I’m using:

workspace.CurrentCamera.CFrame = workspace:WaitForChild("View").CFrame
workspace.CurrentCamera.CameraSubject = workspace.View
workspace.CurrentCamera.CameraType = Enum.CameraType.Fixed

Does anybody know a way to either make Scriptable NOT rotate with mouse movement, or make Fixed go on the right position?

Changing the CameraType property to Scriptable, by default, does not track with mouse movement. Are you sure you are changing the correct Camera object? I believe that when the workspace.CurrentCamera object is destroyed it creates a new, default, camera with its CameraType property set to Fixed - therefore allowing camera rotation with mouse movement. Could this be your problem?

1 Like

Made a loop to print it, it prints Custom when I’m on there…

Is there another way without having to set it every frame?

Got it to work by having a coroutine with this code wrapped to it:

local chr = plr.Character or plr.CharacterAdded:Wait()
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

As the camera would be reset when a character is loaded.

That works. Also, you could bind a function to listen for changes to the Workspace.CurrentCamera property. Whenever this property is changed, call a function which customizes any property of the Camera you need changed:

workspace.Changed:connect(function(propName)
    if propName == "CurrentCamera" and workspace.CurrentCamera then
        workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
   end
end)

Of course you would then need a way to disable this event listener if the CurrentCamera is being reset later in the game and you don’t want its CameraType property to be Scriptable.

1 Like