How to fix this Camera Bug

I making a cutscene script , and it’s working right but when I reset and use it again the camera will bug and stay the position where I die

local player = game.Players.LocalPlayer
local char = player.CharacterAdded:Wait()
local cam = game.Workspace.CurrentCamera
local RunService = game:GetService("RunService")

local replicateRemote =  game.ReplicatedStorage:FindFirstChild("Cutscene"):FindFirstChild("TWDonut")

function Cinematic(folder)
	local CinematicsFolder = folder 

	local FrameTime = 0
	local Connection

	Connection = RunService.RenderStepped:Connect(function(DT)
		local NewDT = DT * 60
		FrameTime += NewDT
		local NeededFrame = CinematicsFolder.Frames:FindFirstChild(tonumber(math.ceil(FrameTime)))
		if NeededFrame then
			cam.CameraType = Enum.CameraType.Scriptable
			char.Humanoid.AutoRotate = false
			cam.CFrame = char.HumanoidRootPart.CFrame * NeededFrame.Value
		else
			Connection:Disconnect()
			char.Humanoid.AutoRotate = true
			cam.CameraType = Enum.CameraType.Custom
		end
	end)
end

replicateRemote.OnClientEvent:Connect(function()
  char.Humanoid.Died:Connect(function()
      char = player.CharacterAdded:Wait()
      cam.CameraSubject = char.Humanoid
      cam.CameraType = Enum.CameraType.Custom
end)

	Cinematic(script.Donut_Camera)
end)

Reset once and use the cutscene move : https://gyazo.com/049d1efc30669316f43177493f924c45 5

1 Like

It is likely because your script is still referring to the old characters CFrames. The easiest thing to do is move the script to StarterCharacterScripts so it gets refreshed when a new character spawns.

If you found this useful, please mark it as a solution so others can find the answer right away. If you have any more questions, feel free to reply and I will answer them for you.

2 Likes