Roblox Studio Bug?! - "MenuCamera is not a valid member of workspace"

There seems to be something wrong with my menu camera. This is the script I have:

> local RunService = game:GetService("RunService")
> local Mouse = game.Players.LocalPlayer:GetMouse()
> local Camera = game.Workspace.CurrentCamera
> 
> local MenuCamera = game.Workspace.MenuCamera
> local Move = 150
> 
> function UpdateCamera()
> 	local Center = MenuCamera.CFrame
> 	local MoveVector = Vector3.new((Mouse.X - Center.X )/Move,(Mouse.Y - Center.Y)/Move, 0)
> 	script.Parent.Frame.PlayButton.Modal = true
> 	Camera.CFrame = MenuCamera.CFrame * CFrame.Angles(math.rad(-(Mouse.Y - Center.Y)/Move), math.rad(-(Mouse.X - Center.X)/Move), 0)
> end
> 
> RunService.RenderStepped:Connect(UpdateCamera)
> 
> script.Parent.Frame.PlayButton.MouseButton1Click:Connect(function()
> 	game.ReplicatedStorage.RemoteEvents.StartGameEvent:FireServer()
> 	Camera.CameraType = Enum.CameraType.Custom
> 	script.Parent:Destroy()
> end)

At the same time, I have a part called “MenuCamera” - spelled exactly the same way, and it is in the workspace.

Here’s the thing, this works PERFECTLY in the ORIGINAL place I made this in, but when I copy and paste everything from that place into the new place, it just doesn’t work. Then, I get the error of

“MenuCamera is not a valid member of Workspace” - this is confusing because it’s literally in the workspace,.

Things I have tried:

I have tried re adding everything.
I have tried using the AI assistant.
I have tried everything and nothing works.

(NOTE: I AM NOT A SCRIPTER, THIS COMES FROM A TUTORIAL ON YOUTUBE)

Here is a quick video of what is supposed to happen: https://youtu.be/hO3zOEu3Phg

1 Like

It’s probably because the localscript handling the menu camera loaded first before the ManuCamera object. Use game.Workspace:WaitForChild("MenuCamera") to prevent the error

I hope this helps!

The thing is when I do that, this happeneds.

The code breaks and gives “MenuCamera” a red line underneath it.

The errror:

1 Like

No what I meant is to replace game.Workspace.MenuCamera with game.Workspace:WaitForChild("MenuCamera").

The variable should look like this:

local MenuCamera = game.Workspace:WaitForChild("MenuCamera")
2 Likes

OH MY GOODNESS MAN!! Thank you so much LOL! I was stuck on this for almost an hour. You’re a hero man

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.