wait(.1)
game.ReplicatedStorage.Remote.CamChange:FireServer()
local run = true
local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
warn("Found the player"..player.Name)
local Helmet = player.Character.Helmet.Handle
--local HelmtTexture = player.Character.Helmet.Handle.TransChange
local CamV = script.Parent.nxtcam.Value
cam.CameraSubject = player.Character.Head
cam.CameraType = ("Follow")

mouse.KeyDown:connect(function (key)
	key = string.lower(key)
	if key == "c" then
		if CamV == ("first") then
			cam.CameraSubject = player.Character.Head
			cam.CameraType = ("Follow")
			CamV = ("third")
			Helmet.Transparency = 0
			--cam.HelmBlur.Enabled = false
			--HelmtTexture.Transparency = 0
		elseif CamV == ("third") then
			CamV = ("first")
		end
	end
end)

script.Parent.CarSeat.Value.ChildRemoved:connect(function(child)
	run = false
	cam.CameraType = "Custom"
	cam.FieldOfView = 80
	cam.CameraSubject = player.Character.Head
	player.CameraMaxZoomDistance = 50
	player.CameraMinZoomDistance = 0
	script:Destroy()
end)

--FIRST PERSON------------------------------------------------------------------------------------------------------------
game:GetService("RunService").RenderStepped:connect(function()
	if run and CamV == "first" then
		local XLook = math.max(math.min(((mouse.X-(mouse.ViewSizeX/2))/300)^3,1),-1)
		local YLook = math.max(math.min(((mouse.Y-(mouse.ViewSizeY/2))/300)^3,1),-1)
		local LookOffset = player.Character.Head.CFrame:toWorldSpace(CFrame.new(0,.1,-.5)*CFrame.Angles(-YLook,-XLook,0))
		cam.CameraType = "Scriptable"
		cam.FieldOfView = 60
		--HelmtTexture.Transparency = 1
		Helmet.Transparency = 1
		--cam.HelmBlur.Enabled = true
		cam.CameraSubject = player.Character.Head
		cam.CoordinateFrame = LookOffset
		player.CameraMaxZoomDistance = 0
	end
end)
---------------------------------------------------------------------------------------------------------------------------

--[[

--THIRD PERSON------------------------------------------------------------------------------------------------------------
game:GetService("RunService").RenderStepped:connect(function()
	if run and CamV == "third" then
		local XLook = math.max(math.min(((mouse.X-(mouse.ViewSizeX/2))/300)^3,1),-1)
		local YLook = math.max(math.min(((mouse.Y-(mouse.ViewSizeY/2))/300)^3,1),-1)
		local LookOffset = player.Character.Head.CFrame:toWorldSpace(CFrame.new(0,2,9)*CFrame.Angles(-YLook,-XLook,0))
		cam.CameraType = "Scriptable"
		cam.FieldOfView = 70
		cam.CameraSubject = player.Character.Head
		cam.CoordinateFrame = LookOffset
		player.CameraMaxZoomDistance = 30
		player.CameraMinZoomDistance = 30
	end
end)
---------------------------------------------------------------------------------------------------------------------------

--]]