Synchronizing Camera Movement with Player Events in Roblox

Want:
I want the player’s camera to move to CameraPart before and after each round. Once the round starts, the camera should follow the HeadCamera’s CFrame and then allow the player to use the camera normally.

Problem:
The camera correctly follows the HeadCamera’s CFrame during the first round but fails to do so in subsequent rounds.

How do I fix this?

Code:

local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera
local CameraPart = game.Workspace.Lobby:WaitForChild("CameraPart")
local GameEvent = game.ReplicatedStorage.RemoteEvents.GameEvent
local HeadCamera = Player.Character.HeadCamera

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CameraPart.CFrame

GameEvent.OnClientEvent:Connect(function(Message)
	if Message == "Ready" then
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = HeadCamera.CFrame
		task.wait(0.25)
		Camera.CameraType = Enum.CameraType.Custom

	elseif Message == "EndGame" then
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = CameraPart.CFrame
	end
end)

The code seems fine to me, maybe the problem is where you fire the event, but you can try setting the camera subject like this:

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = HeadCamera.CFrame
task.wait(0.25)
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = player.Character.Humanoid -- set the camera subject

Also, please don’t repost the same topic.

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