I’m storing the Camera CFrame (and Player position) in the DataStore, so the player can return to the exact same screen view they had when exiting the game.
-- LocalScript
function PlayerAdded(CFramePlayer, CFrameCamera)
Player.Character.HumanoidRootPart.CFrame = CFramePlayer -- last player position
wait() -- avoid a bug when changing CameraType
Camera.CameraType = Enum.CameraType.Scriptable -- to change Camera Cframe
Camera.CFrame = CFrameCamera
Camera.CameraType = Enum.CameraType.Custom -- back to default
end
Everything is ok above, except that, when I change back CameraType
to Custom
, it loses the zoom stored in CFrame.
To simulate this situation, I removed the last line Camera.CameraType = Enum.CameraType.Custom
and leave it only as Scriptable
.
I saved the game with this view:
Then I loaded the game and got the same perspective (PlayerdAdded):
However, if I manually change the CamerarType
from Scriptable
to Custom
(the same way with the line Camera.CameraType = Enum.CameraType.Custom
):
… Studio changes the Camera zoom:
So my question is: How to avoid that CameraType.Custom
changes the current Camera.CFrame?