Camera FOV change when seated?

How do I make when a player is seated on the driveseat the camera fov changes?

2 Likes

Hello. I think the only way to do so would be with RemoteEvents. Maybe try listening to a change on the vehicle seat and tell the player to change its camera field of view.

ServerScript:

local event = game:GetService("ReplicatedStorage").FOV_RE --your remote event

local vehicleSeat = workspace.Car.VehicleSeat -- your vehicle seat

function driverFOV()
	local hummy = script.Parent.Occupant
	if hummy then
		local player = game:GetService("Players")[hummy.Parent.Name]
		event:FireClient(player)
	end
end

vehicleSeat.ChildAdded:Connect(driverFOV)
vehicleSeat.ChildRemoved:Connect(driverFOV)

Local script:

game.ReplicatedStorage.FOV_RE.OnClientEvent:Connect(function()
	local cam =	workspace.CurrentCamera
	if cam.FieldOfView == 70 then
		cam.FieldOfView = 50
	else
		cam.FieldOfView = 70
	end
end)

In this case, the event fires after a “Weld” object is created (which happens automatically when a player sits). Then, the player changes their FOV. You could also send arguments (e.g. IsSeated = true/false) to make this more reliable.

2 Likes

This is very simple but i think that the code will make that when the player touches the seat the fov of the camera will be increased. I hope this helped a bit with the understanding of CameraFov.

local Camera = workspace.CurrentCamera
local plrs = game:GetService("Players")
local plr = Players.LocalPlayer
local seat = script.Parent

seat.Touched:Connect(function(plr)
   Camera.FieldOfView = 70
end

In this case, anyone who touches the seat (regardless of they being the driver or not) would fire the touched event…

1 Like

Yeah I understand that but it was just an simple code, for cameraFOV understanding but thanks for remarking this :smiley:

1 Like

Works, but I need to add the isSeated = true and isSeated = false just like you said.

	local cam =	workspace.CurrentCamera
	if cam.FieldOfView == 70 then
		if isSeated then
		cam.FieldOfView = 50
	else
		cam.FieldOfView = 70
	end
end

Oh wait it did not work at all.