Hello, I'm trying to make a GUI that changes the camera position to the part, here's the script that does so:
local camera = game.Workspace.Camera
wait(0.1)
camera.CFrame = game.Workspace.menucamerapart.CFrame
camera.CameraType = Enum.CameraType.Scriptable
game.Lighting.Brightness = 0
game.Lighting.ClockTime = 0
game.Lighting.FogEnd = 20
In the output, it says "menucamerapart is not a valid member of Workspace "Workspace"
Can I get any help on this?

5 comments
either you haven't named it correctly, or you should be using WaitForChild(). also, you should use CurrentCamera rather than the workspace camera. https://devforum.roblox.com/t/currentcamera-vs-camera/796434
Thank you for your assistance. Your solution has worked. What I did was use CurrentCamera, and used WaitForChild. If you would like to gain reputation, please post your answer.
nah, it doesn’t matter. however, if you do use currentcamera I don’t think you need waitforchild (from experience), just use a dot
What I did in my script was change the workspace camera into CurrentCamera, and used WaitForChild for the camera part.
Changing only the camera to CurrentCamera, still didn't work, but however, using WaitForChild for the camera part, worked.