How do i fix this camera script?

camerascript.lua (234 Bytes)
Hi! I wrote this camera script, and nothiing happened, the camera was normal, whats wrong with it? I put it in ServerScriptService btw. I’d really appreciate if you explain it, rather than just dumping code onto here. Thanks :slight_smile:

local Camera = workspace.CurrentCamera
Camera:GetRenderCFrame()
local pos = Vector3.new(1,10,1)
local lookAt = Vector3.new(1,1,2)
local cameraCFrame = CFrame.new(pos, lookAt)
Camera.CFrame = cameraCFrame
Camera.HeadLocked = true

A camera should only be manipulated from a local script. Because each player has his own camera object, that’s different from another player’s camera. It might seem like all workspaves have a single Camera object, but no each local workspace for each local player has a seperate table.

ServerScriptService is a place for server scripts, only server scripts are supposed to run their.

I assume you used a server script, so change it to a local script and put it inside of StarterGui, you might actually be using a local script, but it’s in serverscriptservice, where it wouldn’t run, so switch to StarteeGui (another possibility might be StarterPlayerScripts)

2 Likes

It didn’t work, camera is still the same. I’ll try StarterPlayerScripts. Nah, neither worked.

Did you switch to a local script?
Also you seem to be requiring Camera:GetRenderCFrame() without setting it to a variable, which is uselss. You’re also not using it. Do

local cf = Camera:GetRenderCFrame()

Camera Manipulation
As the camera is part of the client and isn’t replicated, it must be manipulated in a LocalScript in a client area (i.e StarterPlayerScripts or PlayerScripts).

Take a look at this:

Code Sample (from the link above)

2 Likes