MenuCam is not a valid member of Folder 'Workspace.Menu'

Hi, I’m making a new game and I wanted to make a menu that the player will be greeted with upon joining the game. I put a part in the position I wanted the player camera to be (which is the MenuCam part) and put it in a folder name “Menu” in workspace. When I tried to set the Camera CFrame equal to the MenuCam CFrame, it errors with this:
Screenshot 2024-05-03 154201

This IS written in a local script inside of StartPlayerScripts.

I’ve tried to fix it multiple times by adding FindFirstChild() and/or WaitForChild()
I can confirm that neither of these work, FindFirstChild results in this error:
Screenshot 2024-05-03 154620

WaitForChild does absolutely nothing, so neither of these yield the desired result.

Here’s the kicker: I have another game with this EXACT same setup, and it works flawlessly. I can’t figure this out, and I’m thinking it’s just something wrong with the roblox engine at this point, I don’t know what it is. I’m here for suggestions of things that could be causing this.

Now I have written two scripts to accomplish this (I tried the first one, it didn’t work so I wrote the second one with higher hopes)

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local camera = workspace.CurrentCamera

repeat wait()
	camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType	== Enum.CameraType.Scriptable
camera.CFrame = workspace.Menu.MenuCam.CFrame
camera.FieldOfView = 50

As previously stated, the above script does not work, and neither does the script below.

local players = game:GetService("Players")

local cam = game.Workspace.Camera
local menuCam = game.Workspace.Menu.MenuCam

players.PlayerAdded:Connect(function(player)
	repeat task.wait()
		cam.CameraType = Enum.CameraType.Scriptable
	until cam.CameraType == Enum.CameraType.Scriptable
	print("Setting camera CFrame.")
	cam.CFrame = menuCam.CFrame
	cam.FieldOfView = 55
end)

If anyone has anything that might help me or somebody else who finds this later on, I would greatly appreciate it.

Disclaimer: I read a lot of other threads, and tried all of their solutions, they almost always consisted of the above solutions that I already tried, and as I stated before, they did NOT work.

1 Like

Are you creating the camera in studio? If not, are you creating the camera on the server?

The camera is not replicated to the client in any form so that would cause the behaviour you’re experiencing in both cases. Try creating it on the client at runtime and see if that helps.

Also, players.PlayerAdded won’t fire on the client when the local player joins so that could also be the cause (just bringing that up because of your second snippet).

If you’re already creating it on the client at runtime, it’s gonna require some more debugging. Let me know if this is the case.

1 Like

I don’t understand the questions, what do you mean create the camera in studio?

The second script I added to the start of the thread that contained players.PlayerAdded was the second attempt, the first script was the main script I had/have been using.

Like I also said, this exact same script and part in a folder that is a child of workspace is how I did this exact same thing in another game, and it works.

Why is it that it works in another game, but then I essentially copy and paste it (which I also tried lol) but it doesn’t work in this game

also please be patient, I am still trying to learn how to do this semi-competently :no_mouth:

1 Like

By creating the camera in studio, I mean are you in the editing session and manually adding the camera like this:
image
or are you creating it via script (Instance.new('Camera'))

If you’re doing the first thing, (manually inserting it), the camera won’t be replicated to each player when they join (so for each player the camera won’t exist).

I don’t even think the camera saves when you close out of the editing session if you’re manually inserting

There’s gotta be some factor that’s changing. In the game where it works, is there another script creating the camera?

1 Like

No, the whole script is just this:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local camera = workspace.CurrentCamera

repeat wait()
	camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType	== Enum.CameraType.Scriptable
camera.CFrame = workspace.Menu.MenuCam.CFrame
camera.FieldOfView = 50

Oh, this is what I thought, but I figured my guess was probably wrong.

This is probably going to sound stupid, but I’m using the camera that’s just in workspace by default. I don’t know why but it works in the other game, but not in this one.

edit: I should probably clarify: the MenuCam is a PART that the camera in workspace (game.Workspace.Camera) is having the CFrame set to the CFrame of the MenuCam part.

Like I said, both are IDENTICAL.

The script is copy and pasted now and everything in workspace is also the same.

I just realized my initial read of your post skipped over the fact that you mentioned MenuCam is a part, not a camera, that’s my bad completely, sorry about that

When you call WaitForChild does it give you an infinite yield warning?

Is it possible that MenuCam is either spelled wrong, has a space, different capitalization, or something like that? Is there something that could be reparenting the part elsewhere?

Could you double check that MenuCam is anchored? I’m wondering if it fell out of the world and is being removed

Yes, it does

Unfortunately, it is none of these things either.

Double triple checked, it’s anchored.

1 Like

Is it possible that you have multiple Instances called MenuCam?

2 Likes

There is not, I have checked for this also.

Hmm, can you try just adding print(workspace.Menu) at the top of your script, then in the output, click on it, and see if it selects the folder, or if it selects nothing?

1 Like

You think its possible to provide a rblx. file?

2 Likes

huh, so I just did this and upon joining all I get is “Menu” in the output.

I see the Menu folder, but it’s empty. I’m wondering if something is deleting the part after all.

1 Like

Oh wait I just realized, how far away is this part? Could you try turning off workspace.StreamingEnabled and see if this fixes it?

If still nothing, I’d just double check your scripts and see if there’s anything unanchoring it, parenting it elsewhere, destroying it, calling ClearAllChildren on the menu folder itself, etc (you can use ctrl/cmd + shift + f to search for these)

If you could provide an rbxl file that could also be helpful as mentioned above

2 Likes

I don’t know why I’ve not seen anything on this.

That seems to have fixed it…

Well this seems to have been an overly complicated thing for no reason lol

Thanks for the help, I would have never figured that out otherwise.

2 Likes

On a side note, streaming can help with memory usage since it removes parts based (mostly) on proximity. If you want to keep it on but still have your scripts work, you can add your parts to a model and set the model’s ModelStreamingMode to Persistent and it shouldn’t ever be streamed out

3 Likes

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