Camera system with rotating cameras

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to make a camera system with multiple cameras that turn

  2. What is the issue? Include screenshots / videos if possible!
    I can’t figure out how to make the players camera rotate with the camera model. I used RunService to constantly update the players camera’s CFrame. but the problem came from trying to stop the run service from updating the CFrame when the player exited the camera(clicked the exit button).

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried searching on google, youtube and on the dev forum but found nothing about rotating cameras.

This is my script so far:

local RunService = game:GetService("RunService")

local function updateCamPos(Cam)
	workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
	workspace.CurrentCamera.CameraSubject = workspace.Cameras[Cam]
	workspace.CurrentCamera.CFrame = workspace.Cameras[Cam].CamAttach.CFrame
end

for i, v in pairs(script.Parent:GetChildren()) do
	if v.ClassName == "TextButton" then
		v.MouseButton1Click:Connect(function()
			if v.Name ~= "Exit" then
				local RSConnection = RunService.RenderStepped:Connect(function()
					updateCamPos(v.Name)
				end)
			else
				workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
				workspace.CurrentCamera.CameraSubject = workspace[game.Players.LocalPlayer.Name]:FindFirstChild("Humanoid")
			end
		end)
	end
end

This is a localscript(“click”) inside the ScreenGui the cam buttons are in
image

The RSConnection should get disconnected when switching cameras or exiting the cams entirely, but i just cant figure out how i would implement that.

The cameras themselves already have a script in them that makes them rotate.
The cameras also have another part inside them that the player cam attaches to.

if you need any more info then feel free to ask.

1 Like