Every now and then of testing I Get The Error 'Camera IS not valid member of group Main Menu'

Every now and then when play test testing I Get The Error ‘Camera Is not valid member of group Main Menu’ when it is in the model, it only happens every once and a while and works sometimes, here is the code

local char = game.Players.LocalPlayer.Character
local hum = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

char.Humanoid.WalkSpeed = 0
char.Humanoid.JumpHeight = 0
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
game.Workspace.CurrentCamera.CFrame = game.Workspace.MainMenu.Camera.CFrame
game.SoundService.Horror.Playing = true```


game.Workspace.CurrentCamera.CFrame = game.Workspace.MainMenu:WaitForChild(“Camera”).CFrame

1 Like

You can use :WaitForChild("Camera") to wait for something to replicate that you know exists. This is useful for cases where the server has not automatically replicated objects to a client yet before client code is running.

You can also use :FindFirstChild("Camera") if you want to check if something exists without yielding.

1 Like

I could have sworn that just caused the script not to run last time I tried thanks to both of you

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