How to make the camera to go back to the player when they stand up?

Sorry if the title is confusing haha.

I have 2 scripts that changes the camera of the player to a custom camera, but, while yes it works I have no idea how to put the camera back to the player. I’ve tried just reversing the process but that didn’t work and I don’t know any other way to overcome this problem.

ServerScriptService:

local Seat = game.Workspace.Chair.Seat
local RemoteEvent = game.ReplicatedStorage.RemoteEvents.CamSeat
local RemoteEvent2 = game.ReplicatedStorage.RemoteEvents.PlayerCam

Seat.Changed:Connect(function()  
	if Seat.Occupant ~= nil then
		local Player = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
		RemoteEvent:FireClient(Player)
	end
end)


Seat.Changed:Connect(function()  
	if Seat.Occupant == nil then
		local Player = game.Players:GetPlayers()
		RemoteEvent2:FireClient(Player)
	end
end)

StarterPlayerScripts:

local Seat = script.Parent
local RemoteEvent = game.ReplicatedStorage.RemoteEvents.CamSeat
local RemoteEvent2 = game.ReplicatedStorage.RemoteEvents.PlayerCam
local Camera = game.Workspace.CurrentCamera
local Camera1 = game.Workspace.CameraSeat
local Player = game.Players.LocalPlayer

RemoteEvent.OnClientEvent:Connect(function()
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = Camera1.CFrame
end)

RemoteEvent2.OnClientEvent:Connect(function()
	Camera.CameraType = Enum.CameraType.Track
	Camera.CFrame = Player.Character.Head.CFrame
end)

I’ve also tried finding other DevForum topics for this but none of them helped.

Sorry if it’s a simple solution, I just started actually investing my time to learn lua, but any help is appreciated!

Just use the last two lines in this script to set the camera back to normal. Everything before those lines are part of the example to show that the camera is changed to something random then changed back to normal if you wanted to try it out yourself.

local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

wait(5)

cam.CameraType = Enum.CameraType.Scriptable -- set the camera to scriptable as an example (should work with any camera type)
cam.CFrame = CFrame.new(0, 0, 0) -- send the camera to some random position as part of the example

wait(2)

-- The following is where I change the camera back to normal
cam.CameraType = Enum.CameraType.Custom -- Set camera type back to what it is originally (player cameras are set to 'Custom' by default)
cam.CameraSubject = char.Humanoid -- in case of any change that has happened to the camera subject, I set it back to the character's humanoid
1 Like