Why does this script not work?

Basically, I’m trying to get the player’s camera to position at a part but it doesn’t seem to work.

This is a server script at workspace:

script.Parent.Camera.CameraType = Enum.CameraType.Scriptable

script.Parent.Camera.CameraSubject = workspace.wju

Nothing is showing up in the output, just incase you need to know.

1 Like

Have you tried changing the camera’s CFrame to the position of the part that you want to position the camera at?

Maybe something like:

local currentCamera = workspace.CurrentCamera

currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CameraSubject = workspace.wju
currentCamera.CFrame = workspace.wju.CFrame

1 Like

Yes, didn’t work. This is what I’ve tried:

script.Parent.Camera.CameraType = Enum.CameraType.Scriptable

script.Parent.Camera.CFrame = workspace.wju.CFrame
2 Likes

Tried that, didn’t work and yes, I’ve set the name startpos to my part called wju. Nothing in output.

1 Like

You cant control the camera using server scripts

1 Like

Wouldn’t it be in StarterPlayer scripts?

Yea and it should be in StarterPlayerScripts(or StarterCharacterScripts or RepliactedFirst)

local CurrentCamera = workspace.CurrentCamera

repeat
    task.wait()
    CurrentCamera.CameraType = Enum.CameraType.Scriptable
until CurrentCamera.CameraType = Enum.CameraType.Scriptable

CurrentCamera.CFrame = workspace.wju.CFrame
CurrentCamera.CameraSubject = workspace.wju

print("Set!")

The CFrame needs to be set, in addition to the CameraSubject. I added a repeat loop, it isn’t necessary, but I thought I would just for extra confirmation. This should be a LocalScript, just to let you know!

Additionally, I added a print statement, just for debugging reasons. (Remove it after you test it, it should work!)

Thanks, Cloud. :cloud:

1 Like

The server’s camera’s viewport size is 1x1 pixel, you need to do this on the client instead.

1 Like