Can you set camera CFrame in a module called by the client?

I am currently reworking a game and I can’t seem to set the camera’s CFrame on a module called by the client. However, if I use the exact same code (nothing fancy, just setting the camera type to scriptable and then the CFrame to the CFrame I want) on the local script that calls the module it works just fine. This is a bit inconvenient, and if it is true that you can’t manipulate the camera on a module is there a way to, or is something different, cause manipulating the camera elsewhere would be a bit inconvenient.

It should be totally possible. Want to share the code and I will take a look?

1 Like
local camera = workspace.CurrentCamera
camera.CFrame = CFrame.new()

Yes, very simple to achieve this.

1 Like

Yea I thought so but it does not want to work. This is my code:

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(CarPosition + Vector3.new(-25,10,0), CarPosition)

Already confirmed CarPosition is not nil and the module is being called from the client. Camera is already defined as workspace.CurrentCamera

I am aware that’s how you do it but my issue is that it is not working.

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(CarPosition + Vector3.new(-25,10,0), CarPosition)

Already confirmed CarPosition is not nil and the module is being called from the client. Camera is already defined as workspace.CurrentCamera

Did we take this into account?

Because each player’s camera is local to their device, custom camera code should exist in a LocalScript within StarterPlayerScripts or StarterPack . Placing any of the following scripts elsewhere will not allow the code to properly take control of the camera.

Right but it doesn’t make sense that you can interact with other aspects of the client from a module called from the client but not the camera…

Hmm. That’s very strange.

Have you checked that the code is running by printing in the console?

Also, do you have any other script that may interfere with the camera?

If they both don’t work set a breakpoint on where you set the Players Camera then see what happens.

Try using a local script, It should work

As I said in my original post, it works in a local script but that is inconvenient.

well there really isn’t any work around to this to my knowledge. I tried to do the same with CoreGui and I had to resolve on a remote function that does that