Main Menu Camera System

  1. What do you want to achieve? Keep it simple and clear!
    Force the player’s camera to be at a specific spot then when a UI button is triggered, return it to normal.
  2. What is the issue? Include screenshots / videos if possible!
    Nothing I try moves the camera.
  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    Setting the CFrame to be the same as a part’s, setting the part as the camera’s subject.
local event = game.ReplicatedStorage.mainCameraEvent
--"fix" to fix the camera, "set" to set the menuCam
event.OnServerEvent:Connect(function(player, actionType)
	if actionType == "fix" then
		task.wait(0.5)
		workspace.CurrentCamera.CameraSubject = player.Character.HumanoidRootPart
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		--workspace.CurrentCamera.CameraMode = Enum.CameraMode.Classic
	elseif actionType == "set" then
		task.wait(0.5)
		workspace.CurrentCamera.CameraSubject = workspace.menuCamPos
		workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
		--workspace.CurrentCamera.CameraMode = Enum.CameraMode.LockFirstPerson
	end 
end)
local music = game.Workspace:WaitForChild("musicPlayer")
local menuMusic = game.Workspace.MainMenu.MenuMusic

music.Volume = 0
menuMusic:Play()
game.ReplicatedStorage.mainCameraEvent:FireServer("set")
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	local TweenService = game:GetService("TweenService")
	local CloseTweenInfo = TweenInfo.new(
		1,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)
	local CloseTween = TweenService:Create(player.PlayerGui.MainMenu.Frame, CloseTweenInfo, {Position = UDim2.new(0, 0,-1, 0)})
	CloseTween:Play()
	
	player.Character.HumanoidRootPart.Anchored = false
	workspace.MainMenu.MenuMusic.Volume = 0
	workspace.musicPlayer.Volume = 0.3
	game.ReplicatedStorage.mainCameraEvent:FireServer("fix")
end)

After setting cameratype to scriptable just set its CFrame instead of camerasubject

Do I do that on the server or the client?

How can you even set camera on server? :skull:

Idk, if you cant tell I dont work with the camera a lot.

Just set cframe below that
Should work flawlessly

1 Like

I did

		workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
		workspace.CurrentCamera.CFrame = workspace.menuCamPos.CFrame

But it claims that 14:22:17.892 menuCamPos is not a valid member of Workspace “Workspace” - Client - mainMenuPrep:7 even though it exists.

Its a client…
Just do wait for child.
Make sure instance gets streamed if you have streaming enabled

I thought that didn’t apply for the workspace, since it is already there. That fixed it, thank you.

For client it applies everywhere exept replicated first

1 Like

I havent changed anything with the script and it doesnt work anymore, it just starts up in the normal camera.

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	local TweenService = game:GetService("TweenService")
	local CloseTweenInfo = TweenInfo.new(
		1,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)
	local CloseTween = TweenService:Create(player.PlayerGui.MainMenu.Frame, CloseTweenInfo, {Position = UDim2.new(0, 0,-1, 0)})
	CloseTween:Play()
	
	player.Character.HumanoidRootPart.Anchored = false
	workspace.MainMenu.MenuMusic.Volume = 0
	workspace.musicPlayer.Volume = 0.3
	workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
end)
local music = game.Workspace:WaitForChild("musicPlayer")
local menuMusic = game.Workspace.MainMenu.MenuMusic

music.Volume = 0
menuMusic:Play()
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = workspace:WaitForChild("menuCamPos").CFrame

There isn’t a single error so I am lost on why it doesnt work.

Nevermind about this, I just made the camera a variable and that fixed it somehow

You cant instantly set scriptable
You need to do like:

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera:GetPropertyChangedSignal("CameraType"):Wait()
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

Becouse of core scripts

1 Like