Camera script isn't working

Hello Roblox Community! :cherry_blossom: This is probably a very quick topic to answer, but I’m trying to get a project finished in about 3 hours from now and am fairly stumped on turning the player’s camera to the front surface of a part from the start of the game until they leave.

When I currently join the game, nothing happens and no errors appear in the output, so I assume it’s not an issue the output is detecting, and something is wrong with my logic or CFrame.

Currently the part “Cutscene1” is just in workspace, and the script is a LocalScript in StarterGui.

I did a quick skim of the internet and couldn’t find a working fix, so I decided to ask here to find help. Thank you in advance, code is down below! ~Boba

local camera = game.Workspace.Camera

camera.CameraType = Enum.CameraType.Scriptable

camera.CFrame = CFrame.new(game.Workspace.Cutscene1.Position)

This video right here covers how you would do it.

1 Like

Right, thank you! Turns out that the script was working, but it was working too quick and just needed a wait(5).

Thank you so much! Will mark this solution. :sparkles:

game.Workspace equates to workspace, which reduces character count, and one that I use. It’s a global variable created by Roblox. (although, it really just depends on yourself if you’d want to use it or not)

You should use workspace.Currentcamera to access the camera, not workspace.Camera.

Setting the CameraType can be unreliable because it can sometimes set it before the character spawns in, and when it does, the CameraType will revert back to Custom. To fix this, you can set this on top of your script instead of waiting for 5 seconds, which is more reliable.

local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()

On another note, you can just do

camera.CFrame = game.Workspace.Cutscene1.CFrame

instead of creating an entirely new CFrame.

2 Likes