However, it seems to work only some of the time?
Sometimes the camera goes to where its supposed to, other times the camera stays stationary at the players location but still doesnt follow the player like a normal camera.
The CurrentCamera property refreshes on the client everytime the player’s character is loaded I believe, so the CurrentCamera when a player joins won’t be the same when their character loads. Instead of adding an arbitrary wait(), use player.CharacterAdded:Wait() and see if that makes a difference.
Sorry, if this is being tested in Studio, sometimes Studio can be a bit wonky with the order things are done in, and LocalScripts can execute a lot later then expected. Running this in my own Studio Instance, it gets stuck on waiting for your character to be added since the LocalScript runs AFTER the game loads your character. An easy way to get around this is to just make a loop until the character loads. Usually you should avoid doing this but in this situation it should be fine.
local plr = game.Players.LocalPlayer
repeat task.wait() until plr.Character
local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = game.Workspace:FindFirstChild("MenuCameraPart").CFrame
I believe your problem was the fact you were using FindFirstChild this is due to the fact your code running before that part exists, using WaitForChild will stop your code until that part exists. I hope this helps!
There most always will be a Humanoid but its always safe to wait for it. also do make sure to check if the player exists, else if the player presses play as they’ve reset or anything odd. its going to throw an error as Character doesn’t exist.
One thing to note if you set the CameraSubject to anything other than the humanoid in the player the character wont apply AutoRotate and zooming in to first person will also not automatically move the character. Hence why the best bet is Humanoid if your looking for normal gameplay, but feel free to experiment!
Alr now im confused. I touched nothing, and it suddenly doesnt work anymore.
What happens is:
Click play and then the camera goes to 0, 0, 0 position. I dont know why, I dont have any scripts interfering with the script. It worked, then stopped working.
local plr = game.Players.LocalPlayer
repeat task.wait() until plr.Character
local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
cam.CameraSubject = game.Workspace:FindFirstChild("MenuCameraPart")
cam.CFrame = game.Workspace:FindFirstChild("MenuCameraPart").CFrame