If you have been experiencing trouble with setting the camera subject or the camera cframe to any position and not been able to make it return to the player, here is the solution!
I found this out in a week of trying to fix my cutscene in which the CurrentCamera 's cframe was set to the characters head for smooth cutscenes, but this COMPLETELY broke the firstperson camera and broke movement and rotation and the orbital camera, but after a week of work i have finally figured it out! (this post was made because a bunch of people have asked how to fix this bug but with no reply) so here it is!
First make 2 Remote events in replicated storage to start and stop the cutscene.
Second you want to set the camera to the cframe of the head, a trigger for your cutscene will be good:
(also create all of the below inside of StarterGui (or PlayerGui) )
--Simply trigger this remote to start the cutscene (localscript)
game.ReplicatedStorage.Cutscene.OnClientEvent:Connect(function() --Start
script.Parent.Looped.Value = true
local camera = workspace.CurrentCamera
player = game.Players.LocalPlayer.Name
character = game.Workspace[player]
local part = character:WaitForChild("Head")
camera.CameraSubject = part
wait()
camera.CFrame = part.CFrame
end)
next you want to create a looped bool value (notice the script.Parent.Looped.Value Above)
then you want to create another localscript to exit the cutscene:
game.ReplicatedStorage.Fix.OnClientEvent:Connect(function() --end the cutscene
local camera = workspace.CurrentCamera
player = game.Players.LocalPlayer.Name
character = game.Workspace[player]
local part = character:WaitForChild("Humanoid")
camera.CameraSubject = part
wait()
script.Parent.Looped.Value = false
end)
lastly you want to create a localscript to loop the cframe and exit the cframe
while true do
if script.Parent.Looped.Value == true then -- If the cutscene is on
local camera = workspace.CurrentCamera
player = game.Players.LocalPlayer.Name
character = game.Workspace[player]
local part = character:WaitForChild("Head")
wait(0.1)
camera.CFrame = part.CFrame
else --If the Bool "Looped" is not true (aka if the cutscene is off)
wait(0.4)
local camera = workspace.CurrentCamera
player = game.Players.LocalPlayer.Name
character = game.Workspace[player]
local part = character:WaitForChild("Humanoid")
camera.CameraSubject = part
wait(0.1)
end
end
If this helped you let me know! if you have a more efficient method or issues then also let me know!
if your camera leaves first person when exiting the camera simply set StarterPlayer.CameraMode to LockFirstPerson or Player.CameraMode to LockFirstPerson! Have Fun!