Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to fix the camera where I want it to look?

Basically i'm trying to make a main menu where the it starts the player off in said main menu. I want the camera to focus on a structure I made and not allow the player to move the camera, but only to click on the Menu GUIs to "Play" the game.

Using the wiki on Camera Manipulation I put together the two example scripts it gave using PlayerAdded. This is what I currently have on a local script that is put into the Player's character:

local cam = workspace.CurrentCamera
local LobbyCam = workspace.Lobby.LobbyCam
wait()

cam.CameraType = "Fixed"
cam.CameraSubject = LobbyCam

What's going on is when I press Play to test, the camera stays in the previous position of where I had it in Edit mode instead of where I want it to go.

5 comments

0

Is it a local script?

0

Yes, I said I put it in a local script.

0

try it in a server-side script.

0

#LordDragonZord, you can only access the CurrentCamera client sided.

0

Thanks @ MastaJames

1 answer

Your problem has to do with the CameraType you set. A fixed CameraType does not watch, follow, or rotate with subject (here is a full list of the enums). What you want is a scriptable CameraType, as it allows you to set the CFrame of the camera and the player has no control over it.

Here is an example where you have two parts, one where you want the camera to be located and another that you want it to look at:

local camera = game.Workspace.CurrentCamera

local cameraLocation = game.Workspace.Part1.Position
local cameraTarget = game.Workspace.Part2.Position

camera.CameraType = Enum.CameraType.Scriptable
camera.CoordinateFrame = CFrame.new(cameraLocation, cameraTarget)

This discussion is preserved as it was. New answers, comments, and votes are closed.