MenuCamera is not a valid member of Folder "Workspace.Cameras"

Hello,

I’m trying to make a menu that has a camera connected to it.

For some reason, it says that the Camera is not a valid member of workspace. It worked before.

I’ve tried renaming it, putting it in a folder, but nothing works. Again, it used to work.

Here is a video of my issue.

Here is my code.

local camera = workspace.CurrentCamera
local cameraPos = workspace.Cameras.MenuCamera **--where the error is occurring.**
local playBtn = script.Parent.PlayBtn
local Title = script.Parent.Title
local MMTheme = game.Workspace.Sounds.MainMenuTheme
local MainTheme  = game.Workspace.Sounds.BGMusic
local fader = script.Parent.Fade

local plr = game.Players.LocalPlayer

game.StarterGui.ScreenPlay.Enabled = true
MainTheme.Playing = false
MainTheme.Looped = false
MMTheme.Playing = true
MMTheme.Looped = true
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = cameraPos.CFrame
camera.CameraSubject = cameraPos
camera.FieldOfView = 50

playBtn.MouseButton1Click:Connect(function()
	game:GetService("TweenService"):Create(fader, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()
	task.wait(.01)
	game:GetService("TweenService"):Create(fader, TweenInfo.new(0.2), {BackgroundTransparency = 0}):Play()
	wait(0.5)
	game:GetService("TweenService"):Create(fader, TweenInfo.new(0.2), {BackgroundTransparency = 0}):Play()
	task.wait(.01)
	game:GetService("TweenService"):Create(fader, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()
	local char = plr.Character or plr.CharacterAdded:Wait()
	camera.CameraType = Enum.CameraType.Custom
	camera.CameraSubject = char.Humanoid
	
	MMTheme.Playing = false
	
	MainTheme.Playing = true
	MainTheme.Looped = true
	
	playBtn.Visible = false --if the playBtn were in a frame, you'd do "script.Parent.Enabled = false" (turns off all children in frame.)
	Title.Visible = false
end)

It is in the folder, in workspace. I don’t understand.

image

Please let me know if I did anything wrong. Thank you. (It was working before)

-- Define the Camera and Menu GUI
local camera = game.Workspace.CurrentCamera
local menuGui = script.Parent -- Make sure this script is a child of the GUI

-- Set the initial position and orientation of the Camera
camera.CFrame = CFrame.new(Vector3.new(0, 5, -10), Vector3.new(0, 5, 0))

-- Function to update the Camera based on GUI input
local function updateCamera()
    local yOffset = menuGui.Position.Y.Offset
    local lookAtPosition = Vector3.new(0, yOffset, 0)
    
    -- Adjust the Camera's position and look at the menu
    camera.CFrame = CFrame.new(Vector3.new(0, 5, -10) + lookAtPosition, lookAtPosition)
end

-- Connect the update function to GUI changes (e.g., scrolling)
menuGui:GetPropertyChangedSignal("Position"):Connect(updateCamera)

-- Initial call to set up the camera
updateCamera()

1 Like

Make sure the part is still on its place after running the game. If it isn’t, another script might be changing its parent, or it could be falling off the map if it has Anchored and CanCollide disabled.

1 Like

If something was changing it’s parent, how could I look for it? Do I just have to scavenge through my scripts? Or is there a shortcut?

Also, if I were to play, and look in the folder, and it was still there, would something changing it’s parent be a possibility? If not, everything else you mentioned wasn’t an issue. Is there anything else I could do? Thank you so much!

That’s odd. You can look for scripts changing its parent by going to VIEW > Find All / Replace All and from there look for something like MenuCamera.Parent =.

If this doesn’t work, here are other possible things that could help:

  • Make sure that there aren’t other folders or parts with the same name.
  • Debug by using function :GetFullName() on the part.
  • If for some reason the issue persists, try using :WaitForChild() to wait for the part to load.
1 Like

It worked when I moved it closer to the SpawnPoint. The camera is on a different baseplate that’s a lot of studs away. Thank you for your help! I still don’t know what to do, though, should I do game.Workspace:WaitForChild:["Menu Map"]

To use WaitForChild, just put the name of the instance inside the parenthesis:

game.Workspace:WaitForChild("Menu Map")

2 Likes

Hey @Sarchyx, I put the camera back into workspace, deleted the main menu map, and moved all the things from my menu back into the main map. This time there’s no errors, but nothing changed except for the absence of errors. What do you think happened? I’m sorry for bombarding you with questions. But I believe you can help.

What are you exactly having trouble with? Can you provide the code that’s having problems?

I tried changing a few things, and I changed where the camera was twice, and for some reason it just randomly worked. By worked, I don’t mean the camera worked again, it just didn’t show an error. It still put me straight into the game.

local camera = workspace.CurrentCamera
local cameraPos = workspace:WaitForChild("MenuCamera")
local playBtn = script.Parent.PlayBtn
local Title = script.Parent.Title
local MMTheme = game.Workspace.Sounds.MainMenuTheme
local MainTheme  = game.Workspace.Sounds.BGMusic
local fader = script.Parent.Fade

local plr = game.Players.LocalPlayer

wait(.001)

game.StarterGui.ScreenPlay.Enabled = true
MainTheme.Playing = false
MainTheme.Looped = false
MMTheme.Playing = true
MMTheme.Looped = true

camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = cameraPos.CFrame

camera.CameraSubject = cameraPos
camera.FieldOfView = 50

playBtn.MouseButton1Click:Connect(function()
	game.Workspace["Menu Map"]:Destroy()
	game:GetService("TweenService"):Create(fader, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()
	task.wait(.01)
	game:GetService("TweenService"):Create(fader, TweenInfo.new(0.2), {BackgroundTransparency = 0}):Play()
	wait(0.5)
	game:GetService("TweenService"):Create(fader, TweenInfo.new(0.2), {BackgroundTransparency = 0}):Play()
	task.wait(.01)
	game:GetService("TweenService"):Create(fader, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()
	local char = plr.Character or plr.CharacterAdded:Wait()
	camera.CameraType = Enum.CameraType.Custom
	camera.CameraSubject = char.Humanoid
	
	MMTheme.Playing = false
	
	MainTheme.Playing = true
	MainTheme.Looped = true
	
	playBtn.Visible = false --if the playBtn were in a frame, you'd do "script.Parent.Enabled = false" (turns off all children in frame.)
	Title.Visible = false
end)

This happens because you change the CameraType before roblox sets it to default (custom). Here’s a workaround for this issue:

local camera = workspace.CurrentCamera
local cameraPos = workspace:WaitForChild("MenuCamera")

local cameratype = Enum.CameraType.Scriptable
local cf = cameraPos.CFrame

camera.CameraType = cameratype
camera.CFrame = cf

local Conn = camera:GetPropertyChangedSignal("CameraType"):Connect(function()
	if not (camera.CameraType == cameratype) then
		camera.CameraType = cameratype
		camera.CFrame = cf
	end
end)

-- Conn:Disconnect()

You can disconnect this function when you want it to change it back to normal.

2 Likes

Thank you so SO SO MUCH --------------------- you saved me. have an AMAZING DA

Also, sorry but can you help me put that in my main script? I’m not sure how to implement it completely. Sorry for keeping this going so long I feel really bad haha. @Sarchyx

Sure, with your script it would be something like this:

local camera = workspace.CurrentCamera
local cameraPos = workspace:WaitForChild("MenuCamera")
local playBtn = script.Parent.PlayBtn
local Title = script.Parent.Title
local MMTheme = game.Workspace.Sounds.MainMenuTheme
local MainTheme  = game.Workspace.Sounds.BGMusic
local fader = script.Parent.Fade

local plr = game.Players.LocalPlayer

local cameratype = Enum.CameraType.Scriptable
local cf = cameraPos.CFrame

wait(.001)

game.StarterGui.ScreenPlay.Enabled = true
MainTheme.Playing = false
MainTheme.Looped = false
MMTheme.Playing = true
MMTheme.Looped = true

camera.CameraType = cameratype
camera.CFrame = cf

local Conn = camera:GetPropertyChangedSignal("CameraType"):Connect(function()
	if not (camera.CameraType == cameratype) then
		camera.CameraType = cameratype
		camera.CFrame = cf
	end
end)

camera.CameraSubject = cameraPos
camera.FieldOfView = 50

playBtn.MouseButton1Click:Connect(function()
	game.Workspace["Menu Map"]:Destroy()
	game:GetService("TweenService"):Create(fader, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()
	task.wait(.01)
	game:GetService("TweenService"):Create(fader, TweenInfo.new(0.2), {BackgroundTransparency = 0}):Play()
	wait(0.5)
	game:GetService("TweenService"):Create(fader, TweenInfo.new(0.2), {BackgroundTransparency = 0}):Play()
	task.wait(.01)
	game:GetService("TweenService"):Create(fader, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()
	local char = plr.Character or plr.CharacterAdded:Wait()
    Conn:Disconnect() -- disconnect the function
	camera.CameraType = Enum.CameraType.Custom
	camera.CameraSubject = char.Humanoid
	
	MMTheme.Playing = false
	
	MainTheme.Playing = true
	MainTheme.Looped = true
	
	playBtn.Visible = false --if the playBtn were in a frame, you'd do "script.Parent.Enabled = false" (turns off all children in frame.)
	Title.Visible = false
end)

Please tell me if there are any errors.

Yes, it works! Thank you so much @Sarchyx But the only thing im concerned about is the UI not showing up. The camera and everything works, but I cant click play and disconnect the function because the UI isnt showing. Do you know why this is? UI Visibility is true. I’m not sure what the issue is…

Other than that, thank you so much for sticking with me and how dumb I am haha.

Everything worked out. Thank you so much and have an amazing day @Sarchyx

1 Like

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