Camerasubject doesnt go back to the player

Im making a script that when the player jumps out of the train, the camera subject goes back to the player, but when i jump the camera stays on the train

local Keybinds = game:GetService("ReplicatedStorage").Events.Keybinds
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Player = game:GetService("Players").LocalPlayer
local KeyMappings = {
	[Enum.KeyCode.Q] = "Q",
	[Enum.KeyCode.E] = "E",
	[Enum.KeyCode.G] = "G"
}

UIS.InputBegan:Connect(function(input, isTyping)
	if isTyping then return end
	
	local keyCode = input.KeyCode
	local mapping = KeyMappings[keyCode]
	if mapping then
		print(mapping)
		Keybinds:FireServer(mapping)
	end
end)

--when the player jumps change the camera subject to the player

Player.Character.Humanoid.Jumping:Connect(function()
	workspace.CurrentCamera.CameraSubject = Player.Character.Humanoid
	print("fini")
end)

script.TrainUI.Drive.CamButton.MouseButton1Click:Connect(function()
	local functionletter = "G"
	print(functionletter)
	Keybinds:FireServer(functionletter)
end)

RunService.RenderStepped:Connect(function()
	local Train = script.Train.Value
	if Train then
		local Base = Train.Chassis:FindFirstChild("Base")
		local LinearVelocity = Base:WaitForChild("LinearVelocity")
		script.TrainUI.Drive.Vitesse.Text = math.floor(LinearVelocity.LineVelocity)
		if Train.Chassis.Data.Direction.Value == 1 then
			script.TrainUI.Drive.Direction.Text = "Avant"
			workspace.CurrentCamera.CameraSubject = Train.Chassis.VehicleSeat
		elseif Train.Chassis.Data.Direction.Value == 0 then
			script.TrainUI.Drive.Direction.Text = "Arrière"
			workspace.CurrentCamera.CameraSubject = Train.Train._4.CamPart
		end
	end
end)
1 Like

Try setting the camera subject to the character directly instead of the humanoid

workspace.CurrentCamera.CameraSubject = Player.Character

i’ve tried that and i still have the same problem

Add another line as follows:
Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom

I am pretty sure this sets the camera back to roblox’s default camera.

I’ve tried that but i still hace the same problem