Something setting the camera's CFrame and CameraType on it's own

  1. What do you want to achieve?
    I manually set the camera’s CameraType and CFrame when the player joins the game. The camera on it’s own moves down some. I have a suspicion that it is the built-in camera scripts, but I’m not sure.
  2. What is the issue? Include screenshots / videos if possible!
    Here is my camera script:
local camera = workspace.CurrentCamera

local cameraHeight = 90
local cameraCFrame = CFrame.new(Vector3.new(0, cameraHeight, 0), Vector3.new(0, 0, 0))
local fov = 60

local function setCameraType()
    print("Setting camera type")

    if camera.CameraType ~= Enum.CameraType.Scriptable then
        camera.CameraType = Enum.CameraType.Scriptable
        camera.FieldOfView = fov
        camera.CFrame = cameraCFrame
    end
end

-- Camera somehow gets set to Custom on its own, so I set it to Scriptable when it gets changed
camera:GetPropertyChangedSignal("CameraType"):Connect(setCameraType)

setCameraType()

while wait(1) do
    print(camera.CFrame)
end

Output:
image
As you can see, I set the camera to Scriptable every time it tries to set itself, and I also set it’s CFrame. It still manages to change it’s CFrame. When in an actual game (played on the website, not in Studio), the position gets changed to 0, 16.25, 0. I have no idea why this occurs, as this script is the only place I do anything with the camera.

EDIT:
I know I don’t have some kind of malicious script in my game, because I did Ctrl + Shift + F and searched “Camera”, and the only lines that came up are from the script I just showed.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked on the DevForum and Google, and can’t find anything about it there.

I can’t reproduce this, sadly.

Edit: I did notice another issue. In both of our examples, we are getting 86.25 on the Y. I moved the LocalScript to StarterCharacterScripts and I am now consistently getting 90 in both Studio and live server. I think this may be a factor in what you’re seeing.

Image

RobloxPlayerBeta_KKIBUtpJBY

1 Like

I still don’t know what’s causing this, but here’s a fix for anyone else that’s having this problem as well.

local camera = workspace.CurrentCamera

local cameraHeight = 90
local cameraCFrame = CFrame.new(Vector3.new(0, cameraHeight, 0), Vector3.new(0, 0, 0))
local fov = 60

-- Fix camera type and CFrame changing

local function setCameraCFrame()
    if camera.CFrame ~= cameraCFrame then
        print("Camera CFrame changed")

        camera.CFrame = cameraCFrame
    end
end

local function setCameraType()
    if camera.CameraType ~= Enum.CameraType.Scriptable then
        print("Setting camera type")

        camera.CameraType = Enum.CameraType.Scriptable
        camera.FieldOfView = fov

        setCameraCFrame()
    end
end

-- Camera somehow gets set to Custom on its own, so I set it to Scriptable when it gets changed
camera:GetPropertyChangedSignal("CameraType"):Connect(setCameraType)

camera:GetPropertyChangedSignal("CFrame"):Connect(setCameraCFrame)

setCameraType()

This is my entire camera script. What it does it it connects to property changed signals to detect when it’s being changed and set it what it’s supposed to be. You can change it to fit your game if you need to use this.