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

Camera is a part of workspace, but script says it isn't?

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

0

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

1

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.

0

nah, it doesn’t matter. however, if you do use currentcamera I don’t think you need waitforchild (from experience), just use a dot

1

What I did in my script was change the workspace camera into CurrentCamera, and used WaitForChild for the camera part.

1

Changing only the camera to CurrentCamera, still didn't work, but however, using WaitForChild for the camera part, worked.

1 answer

✓ Accepted answer

well if nobody else is going to answer this question in the answers then can i have reputation

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