MainMenuCamera is not a valid member of Workspace "Workspace"

Hello It’s my first time posting on the devforum I have recently ran into a error that says that the MainMenuCamera part is not a valid member of the workspace even though it is.

I have tried re adding the part to no success I have tried to do it with WaitForChild() with little to no success FindFirstChild() also did not work

local player = game.Players.LocalPlayer
local character = player.CharacterAdded
local Mouse = player:GetMouse()
local camera = game.Workspace.CurrentCamera
local runService = game:GetService("RunService")

local defaultCframe = camera.CFrame

local connection

connection = runService.RenderStepped:Connect(function()
	wait()
	camera.CFrame = game.Workspace.MainMenuCamera.CFrame
end)


game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
	connection = runService.RenderStepped:Connect(function()
		wait()
		camera.CFrame = game.Workspace.MainMenuCamera.CFrame
	end)
end)

script.Parent.MouseButton1Click:Connect(function()
	wait(0.2)
	camera.CameraType = Enum.CameraType.Custom
	player:LoadCharacter()

	connection:Disconnect()
end)

Maybe you turned off CanCollide and you didn’t anchor it?

Its anchored and CanCollide is on, It did not work.

Check if you spelled it right, it might be spelled wrong

Tried, Still broken its not working

No longer need help I fixed it, For some weird reason the player had to be close to the part or It wouldn’t work

check if StreamingEnabled is on

also

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Mouse = player:GetMouse()
local camera = game.Workspace.CurrentCamera
local runService = game:GetService("RunService")
local camerapart = workspace:WaitForChild("MainMenuCamera")

local defaultCframe = camera.CFrame

local connection

connection = runService.RenderStepped:Connect(function()
	task.wait()
	camera.CFrame = camerapart.CFrame
end)


character:WaitForChild("Humanoid").Died:Connect(function()
	connection = runService.RenderStepped:Connect(function()
		task.wait()
		camera.CFrame = camerapart.CFrame
	end)
end)

script.Parent.MouseButton1Click:Connect(function()
	task.wait(0.2)
	camera.CameraType = Enum.CameraType.Custom
	player:LoadCharacter()

	connection:Disconnect()
end)

Yeah that was the problem thanks for fixing it!

1 Like

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