Camera help script

Hello everyone , i tried to make a script to make all camera of all players are changing to a part and at a moment all cameras are back to the player ( i want in a script not local )

Could someone can help me pls?

Here is my main script :

game.Players.PlayerAdded:Connect(function(Player)
	IntroEvent:FireClient(Player)
end)


wait(14.5)
local function MainGame()
	
	print("game start")
	game.Workspace.SoundsEffects["Car Engine"]:Play()
	ToggleDialogueEvent:FireAllClients(true)
	

	**cam.CameraType = Enum.CameraType.Scriptable**
           **CFrame = workspace.CamPart4.CFrame**

	DialogueEvent:FireAllClients("You : Damn...")
	workspace.SoundsEffects.Fuel:Play()
	wait(4)
	DialogueEvent:FireAllClients("You : the car does not have any more fuel, we will have to stop here. ")
	wait(4)
	workspace.SoundsEffects.Fuel:Stop()
	wait(3)
	game.Workspace.SoundsEffects["Car Engine"]:Stop()
	workspace.SoundsEffects.CarDoor:Play()

	**cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid**
	**cam.CameraType = Enum.CameraType.Custom**

	ToggleDialogueEvent:FireAllClients(false)
	
	game.Workspace.SoundsEffects.Foret:Play()
	
	for _,player in pairs(game:GetService("Players"):GetPlayers())do
		if player and player.Character then
			player.Character:MoveTo(part.Position)
		end
	end

Do you mean like a cutscene kind of? Like all the cameras focus a part and then go back to their respective players?

Yeah like at a moment all cameras are going to a part and at another moment that go back to respecting players ( also the script for that its :

**cam.CameraType = Enum.CameraType.Scriptable**
          **CFrame = workspace.CamPart4.CFrame**
**cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid**
	**cam.CameraType = Enum.CameraType.Custom**

Use a remote event and fire it to all clients, then use a localscript in player gui to change the camera there.

in local script:

local function ScriptableCamera()
  local cam = workspace.CurrentCamera
  local subject = cam.CameraSubject
  local cameraType = cam.CameraType
  local focus = cam.Focus
  cam.CameraType = Enum.CameraType.Scriptable
  return function()
    cam.CameraType = cameraType
    cam.CameraSubject = subject
    cam.Focus = focus
  end
end

game.ReplicatedStorage.CutsceneToPart.OnClientEvent:Connect(function(Part, TimeToPart, TimeToPause, TimeToBack)
  local cam = workspace.CurrentCamera
  local returnCamera = ScriptableCamera()
  local returnCFrame = cam.CFrame
  -- Use tweenService to tween camera to Part.CFrame and then another tween to go from Part.CFrame to returnCFrame
  
  returnCamera()
end)

In server script:

game.ReplicatedStorage.CutsceneToPart:FireAllClients(workspace.CutsceneCameraPart, 1, 3, 1)

TweenService
In this code, you need to add a remote event called CutsceneToPart inside of ReplicatedStorage.
Also I assumed there’s a part called CutsceneCameraPart that all player cameras should tween to. I also didn’t write the tween code.

Additionally, there’s no way to modify a player’s camera from the server. That’s because the camera is a localized object.

1 Like