Reenabling Humanoid.AutoRotate not working after cutscene

I am working on a horror game, and I am creating a starting cutscene. However, I am encountering an issue where, after the cutscene ends, the character does not rotate with the camera, even after reenabling Humanoid.AutoRotate.

Here is a video of the issue:

As you can see, when the cutscene ends, I move my camera around, but my character remains facing the same direction.

Cutscene Script:

local State = false
local camera = workspace.CurrentCamera
local Offset

game.ReplicatedStorage.Remotes.CameraClient.OnClientEvent:Connect(function(state, subject)
	State = state
	print(State)
	if State == true then
		camera.CameraType = Enum.CameraType.Scriptable
		camera.CameraSubject = subject
	elseif State == false then
		camera.CameraType = Enum.CameraType.Custom
		--camera.CameraSubject = subject
		print(camera.CameraType)
	end
end)

game:GetService("RunService").RenderStepped:Connect(function()
	if State == true then
		local subject = camera.CameraSubject
		if subject then
			if subject:IsA("BasePart") then
				camera.CFrame = camera.CameraSubject.CFrame
			end
			if subject:IsA("Attachment") then
				camera.CFrame = camera.CameraSubject.WorldCFrame
			end
		end
	end
end)

Chapter Module:

local chapter = {}

chapter.Name = "Just An Ordinary Day"

local assets = script.Assets

local defaultWalkspeed = 8

function chapter.start()
	for _, v in pairs(assets:GetChildren()) do
		local workspaceObjects = assets:FindFirstChild("Object_Workspace") and assets.Object_Workspace.Value
		if workspaceObjects then
			local apartment = workspaceObjects:FindFirstChild("Objects") and workspaceObjects.Objects:FindFirstChild("Apartment")
			print(apartment)
			if not apartment then continue end

			local mainRoom = apartment:FindFirstChild("Room")
			print(mainRoom)
			if not mainRoom then continue end

			local players = game.Players:GetPlayers()

			for _, player in pairs(players) do
				coroutine.wrap(function()
					local character = player.Character
					if character then
						local root = character:FindFirstChild("HumanoidRootPart")
						local head = character:FindFirstChild("Head")
						local humanoid = character:FindFirstChild("Humanoid")

						for _, v in pairs(character:GetChildren()) do
							if v:IsA("Accessory") then
								v:Destroy()
							end
							if v:IsA("Hat") then
								v:Destroy()
							end
						end

						if root and head and humanoid then
							humanoid.AutoRotate = false
							root.Anchored = true
							root.CFrame = mainRoom.CutscenePlayer.CFrame
							game.ReplicatedStorage.Remotes.CameraClient:FireClient(player, true, head)
							local animation = Instance.new("Animation")
							animation.AnimationId = "rbxassetid://124258470218223"
							local track = humanoid:LoadAnimation(animation)
							print("play")
							track:Play()
							track.Looped = false
							track.Stopped:Wait()
							root.CFrame = mainRoom.BedTeleportExit.CFrame
							game.ReplicatedStorage.Remotes.CameraClient:FireClient(player, false, humanoid)
							game.ReplicatedStorage.Remotes.FirstPersonCamera:FireClient(player, true)
							humanoid.WalkSpeed = defaultWalkspeed
							humanoid.CameraOffset = Vector3.new(0,0,0.5)
							root.Anchored = false
							humanoid.AutoRotate = true
						end
					end
				end)()
			end
		end
	end
end

return chapter

*Camera Module (For First Person View)

local camera = {}

-- Services
print(game:GetService("RunService"):IsClient())
local Player = game.Players.LocalPlayer
print(Player)
local Mouse = Player:GetMouse()
local Camera = game:GetService("Workspace").CurrentCamera
local UserInputService = game:GetService("UserInputService")
local Humanoid = Player.Character:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")

-- Variables
local bobbingConnection
local FPMaximumDistance = 0.6
local FirstPersonLocalTransparency = 0
local ThirdPersonLocalTransparency = 0
local cameraState = false  -- To track if the first-person effect is enabled

local func1, func2, func3, func4, val, val2, int, int2 = 0, 0, 0, 0, 0, 0, 10, 10
local vect3 = Vector3.new()

-- Lerp function
local function lerp(a, b, c)
	return a + (b - a) * c
end

-- Toggle First-Person Camera Effect
function camera.toggleFirstPersonEffect(enable)
	if enable then
		camera.activate()
		Humanoid.AutoRotate = true
	else
		if bobbingConnection then
			bobbingConnection:Disconnect()
		end
		Player.CameraMaxZoomDistance = 100
		Player.CameraMinZoomDistance = 0.5
		Humanoid.CameraOffset = Vector3.new(0, 0, 0)
		cameraState = false
	end
end

-- Camera bobbing effect while walking
function camera.activate()
	cameraState = true
	bobbingConnection = RunService.RenderStepped:Connect(function(deltaTime)
		deltaTime = deltaTime * 60
		if Humanoid.Health <= 0 then
			bobbingConnection:Disconnect()
			return
		end

		local rootMagnitude = Humanoid.RootPart and Vector3.new(Humanoid.RootPart.Velocity.X, 0, Humanoid.RootPart.Velocity.Z).Magnitude or 0
		local calcRootMagnitude = math.min(rootMagnitude, 50)
		if deltaTime > 3 then
			func1 = 0
			func2 = 0
		else
			func1 = lerp(func1, math.cos(tick() * 0.5 * math.random(10, 15)) * (math.random(5, 20) / 200) * deltaTime, 0.05 * deltaTime)
			func2 = lerp(func2, math.cos(tick() * 0.5 * math.random(5, 10)) * (math.random(2, 10) / 200) * deltaTime, 0.05 * deltaTime)
		end

		Camera.CFrame = Camera.CFrame * (CFrame.fromEulerAnglesXYZ(0, 0, math.rad(func3)) * 
			CFrame.fromEulerAnglesXYZ(math.rad(func4 * deltaTime), math.rad(val * deltaTime), val2) *
			CFrame.Angles(0, 0, math.rad(func4 * deltaTime * (calcRootMagnitude / 5))) *
			CFrame.fromEulerAnglesXYZ(math.rad(func1), math.rad(func2), math.rad(func2 * 10)))

		val2 = math.clamp(lerp(val2, -Camera.CFrame:VectorToObjectSpace((Humanoid.RootPart and Humanoid.RootPart.Velocity or Vector3.new()) / math.max(Humanoid.WalkSpeed, 0.01)).X * 0.08, 0.1 * deltaTime), -0.35, 0.2)
		func3 = lerp(func3, math.clamp(UserInputService:GetMouseDelta().X, -2, 2), 0.25 * deltaTime)
		func4 = lerp(func4, math.sin(tick() * int) / 5 * math.min(1, int2 / 10), 0.25 * deltaTime)

		if rootMagnitude > 1 then
			val = lerp(val, math.cos(tick() * 0.5 * math.floor(int)) * (int / 200), 0.25 * deltaTime)
		else
			val = lerp(val, 0, 0.05 * deltaTime)
		end

		if rootMagnitude > 12 then
			int = 20
			int2 = 18
		elseif rootMagnitude > 0.1 then
			int = 12
			int2 = 14
		else
			int2 = 0
		end

		Player.CameraMaxZoomDistance = 0.5
		Player.CameraMinZoomDistance = 0.5
		vect3 = lerp(vect3, Camera.CFrame.LookVector, 0.125 * deltaTime)
	end)
end

-- Set character transparency based on first or third person
local function setCharacterLocalTransparency(transparency)
	for _, part in pairs(Player.Character:GetChildren()) do
		if part:IsA("BasePart") and part.Name ~= "Head" then
			part.LocalTransparencyModifier = transparency
		end
	end
end

RunService.RenderStepped:Connect(function()
	local isFirstPerson = (Player.Character.Head.CFrame.Position - Camera.CFrame.Position).Magnitude < FPMaximumDistance
	if isFirstPerson then
		setCharacterLocalTransparency(FirstPersonLocalTransparency)
	else
		setCharacterLocalTransparency(ThirdPersonLocalTransparency)
	end
end)

return camera

I tried adding a function to the camera module to disable and enable the rotation, which initially worked, but caused the cutscene to freak out.

When I disable Humanoid.AutoRotate the first time, it works, it’s just reenabling it that’s the issue.

Any guidance or suggestions would be greatly appreciated!

Hi! I found why this happens.

elseif State == false then
	camera.CameraType = Enum.CameraType.Custom
	--camera.CameraSubject = subject   <<<<<<<Here
	print(camera.CameraType)
end

script don’t change CameraSubject back to Humanoid,
you just need to remove this comment

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.