local c=false local m=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local V=0 local R=0 local O=0 local L=0 local Z=0 local D=0 local f=0 local d=0 local v=0 local a=0 local b=0 function DealWithInput(m,y)if c then if m.KeyCode==Enum.KeyCode.ButtonX then if m.UserInputState==Enum.UserInputState.Begin then D=1 elseif m.UserInputState==Enum.UserInputState.End then D=0 end elseif m.KeyCode==Enum.KeyCode.ButtonY then if m.UserInputState==Enum.UserInputState.Begin then f=1 elseif m.UserInputState==Enum.UserInputState.End then f=0 end elseif m.KeyCode==Enum.KeyCode.ButtonL1 then if m.UserInputState==Enum.UserInputState.Begin then d=1 elseif m.UserInputState==Enum.UserInputState.End then d=0 end elseif m.KeyCode==Enum.KeyCode.ButtonR1 then if m.UserInputState==Enum.UserInputState.Begin then v=1 elseif m.UserInputState==Enum.UserInputState.End then v=0 end elseif m.KeyCode==Enum.KeyCode.DPadLeft then if m.UserInputState==Enum.UserInputState.Begin then b=1 elseif m.UserInputState==Enum.UserInputState.End then b=0 end elseif m.KeyCode==Enum.KeyCode.ButtonR3 then if m.UserInputState==Enum.UserInputState.Begin then a=1 elseif m.UserInputState==Enum.UserInputState.End then a=0 end end if m.UserInputType.Name:find("\071\097\109\101\112\097\100")then if m.KeyCode==Enum.KeyCode.Thumbstick1 then V=m.Position.X elseif m.KeyCode==Enum.KeyCode.Thumbstick2 then R=m.Position.X O=m.Position.Y elseif m.KeyCode==Enum.KeyCode.ButtonR2 then L=m.Position.Z elseif m.KeyCode==Enum.KeyCode.ButtonL2 then Z=m.Position.Z end end end end m.InputBegan:connect(DealWithInput)m.InputChanged:connect(DealWithInput)m.InputEnded:connect(DealWithInput)car.DriveSeat.ChildRemoved:connect(function(c)if c.Name=="\083\101\097\116\087\101\108\100"then for c,m in pairs(Binded)do run:UnbindFromRenderStep(m)end workspace.CurrentCamera.CameraType=Enum.CameraType.Custom workspace.CurrentCamera.FieldOfView=70 player.CameraMaxZoomDistance=200 end end)local y=.95 run.Stepped:connect(function()V01=(Sus.CurrentLength^2.0+Sus2.CurrentLength^2.0)^.5 local c=(Sus3.CurrentLength-Sus4.CurrentLength)/1.32 local m=(Sus4.CurrentLength-Sus3.CurrentLength)/1.32 V02=c local V=3.0-V01 local R=(V-.1)/1.98 local O=V02 local L=O/3.98 m1.CurrentAngle=m1.CurrentAngle*y+R*(1-y)m2.CurrentAngle=m2.CurrentAngle*y+(-L/3.98)*(1-y)end)function Camera()local c=workspace.CurrentCamera local m=false local V=0 local L=0 local Z=0 local D=0 local f=0 local d=0 local function v()if not pcall(function()if d==0 and b==1 then m=not m end d=b if D==1 then if math.abs(R)>.1 then local c=1 if R<0 then c=-1 end if m then V=(c*math.abs((math.abs(R)-.1)/.9))*-80 else V=(c*math.abs((math.abs(R)-.1)/.9))*-90 end else V=0 end if math.abs(O)>.1 then local c=1 if O<0 then c=-1 end if m then Z=(c*math.abs((math.abs(O)-.1)/.9))*30 else Z=math.min((c*math.abs((math.abs(O)-.1)/.9))*-75,30)end else Z=0 end else if V>f then V=math.max(f,V-20)elseif V<f then V=math.min(f,V+20)end Z=0 end if m then L=0 else L=-180*a end if m then c.CameraSubject=player.Character.Humanoid c.CameraType=Enum.CameraType.Scriptable c.FieldOfView=70+car.DriveSeat.Velocity.Magnitude/40 player.CameraMaxZoomDistance=5 local m=car.Misc.ActualCam.Parts.Cam.CFrame if a==1 then m=car.Body.RCam.CFrame end c.CoordinateFrame=(m*CFrame.Angles(0,math.rad(V+L),0))*CFrame.Angles(math.rad(Z),0,0)else c.CameraSubject=car.DriveSeat c.FieldOfView=70 if D==0 then c.CameraType=Enum.CameraType.Custom player.CameraMaxZoomDistance=400 run:UnbindFromRenderStep("\067\097\109\085\112\100\097\116\101")else c.CameraType="\083\099\114\105\112\116\097\098\108\101"local m=math.min(1,car.DriveSeat.Velocity.Magnitude/500)local R=((car.DriveSeat.Position+Vector3.new(0,8+m*2,0))-(car.DriveSeat.CFrame*CFrame.Angles(math.rad(Z),math.rad(V+L),0)).lookVector*17)+(car.DriveSeat.Velocity.Unit*-7)*m c.CoordinateFrame=CFrame.new(R,car.DriveSeat.Position)end end end)then c.FieldOfView=70 c.CameraSubject=player.Character.Humanoid c.CameraType=Enum.CameraType.Custom player.CameraMaxZoomDistance=400 run:UnbindFromRenderStep("\067\097\109\085\112\100\097\116\101")end end local function y()if GMode~=D then D=GMode run:BindToRenderStep("\067\097\109\085\112\100\097\116\101",Enum.RenderPriority.Camera.Value,v)end end mouse.KeyDown:connect(function(c)if c==""then f=50 elseif c==""then if m then f=-160 else f=-180 end elseif c==""then f=-50 elseif c=="\118"then run:UnbindFromRenderStep("\067\097\109\085\112\100\097\116\101")m=not m run:BindToRenderStep("\067\097\109\085\112\100\097\116\101",Enum.RenderPriority.Camera.Value,v)end end)mouse.KeyUp:connect(function(c)if c==""and f==50 then f=0 elseif c==""and(f==-160 or f==-180)then f=0 elseif c==""and f==-50 then f=0 end end)run:BindToRenderStep("\067\077\067\104\097\110\103\101",Enum.RenderPriority.Camera.Value,y)table.insert(Binded,"\067\097\109\085\112\100\097\116\101")table.insert(Binded,"\067\077\067\104\097\110\103\101")end Camera()mouse.KeyDown:connect(function(m)if m==""then if GMode>=1 then GMode=0 else GMode=GMode+1 end if GMode==1 then c=true else c=false end end end)

local Controller=false
local UserInputService = game:GetService("UserInputService")
local LStickX = 0
local RStickX = 0
local RStickY = 0
local RTriggerValue = 0
local LTriggerValue = 0

local ButtonX = 0
local ButtonY = 0
local ButtonL1 = 0
local ButtonR1 = 0
local ButtonR3 = 0
local DPadUp = 0
function DealWithInput(input,IsRobloxFunction)
	if Controller then
		if input.KeyCode ==Enum.KeyCode.ButtonX then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonX=1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonX=0
			end
		elseif input.KeyCode ==Enum.KeyCode.ButtonY then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonY=1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonY=0
			end
		elseif input.KeyCode ==Enum.KeyCode.ButtonL1 then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonL1=1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonL1=0
			end
		elseif input.KeyCode ==Enum.KeyCode.ButtonR1 then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonR1=1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonR1=0
			end
		elseif input.KeyCode ==Enum.KeyCode.DPadLeft then
			if input.UserInputState == Enum.UserInputState.Begin then
				DPadUp=1
			elseif input.UserInputState == Enum.UserInputState.End then
				DPadUp=0
			end
		elseif input.KeyCode ==Enum.KeyCode.ButtonR3 then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonR3=1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonR3=0
			end
		end
		if input.UserInputType.Name:find("Gamepad") then --it's one of 4 gamepads
			if input.KeyCode == Enum.KeyCode.Thumbstick1 then
				LStickX = input.Position.X
			elseif input.KeyCode == Enum.KeyCode.Thumbstick2 then
				RStickX = input.Position.X
				RStickY = input.Position.Y
			elseif input.KeyCode == Enum.KeyCode.ButtonR2 then--right shoulder
				RTriggerValue = input.Position.Z
			elseif input.KeyCode == Enum.KeyCode.ButtonL2 then--left shoulder
				LTriggerValue = input.Position.Z
			end
		end
	end
end
UserInputService.InputBegan:connect(DealWithInput)
UserInputService.InputChanged:connect(DealWithInput)--keyboards don't activate with Changed, only Begin and Ended. idk if digital controller buttons do too
UserInputService.InputEnded:connect(DealWithInput)

car.DriveSeat.ChildRemoved:connect(function(child)
	if child.Name=="SeatWeld" then
		for i,v in pairs(Binded) do
			run:UnbindFromRenderStep(v)
		end 
		workspace.CurrentCamera.CameraType=Enum.CameraType.Custom
		workspace.CurrentCamera.FieldOfView=70
		player.CameraMaxZoomDistance=200
	end
end)
local Transition = 0.95
run.Stepped:connect(function()
	V01 = ((Sus.CurrentLength^2.0) + (Sus2.CurrentLength^2.0))^0.50
	local V1 = (Sus3.CurrentLength - Sus4.CurrentLength)/1.32
	local V2 = (Sus4.CurrentLength - Sus3.CurrentLength)/1.32
	V02 = V1
	local V1 = 3.0 - V01
	local V2 = (V1-0.1)/1.98
	local FL = V02
	local FL1 = FL/3.98
	m1.CurrentAngle = m1.CurrentAngle*Transition + (V2)*(1-Transition)
	m2.CurrentAngle = m2.CurrentAngle*Transition + (-FL1/3.98)*(1-Transition)
	
end)
function Camera()
	local cam=workspace.CurrentCamera
	local intcam=false
	local CRot=0
	local CBack=0
	local CUp=0
	local mode=0
	local look=0
	local camChange = 0
	local function CamUpdate()
		if not pcall (function()
			if camChange==0 and DPadUp==1 then
				intcam = not intcam
			end
			camChange=DPadUp
			if mode==1 then
				if math.abs(RStickX)>.1 then
					local sPos=1
					if RStickX<0 then sPos=-1 end
					if intcam then
						CRot=sPos*math.abs(((math.abs(RStickX)-.1)/(.9)))*-80
					else
						CRot=sPos*math.abs(((math.abs(RStickX)-.1)/(.9)))*-90
					end
				else
					CRot=0
				end
				if math.abs(RStickY)>.1 then
					local sPos=1
					if RStickY<0 then sPos=-1 end
					if intcam then
						CUp=sPos*math.abs(((math.abs(RStickY)-.1)/(.9)))*30
					else
						CUp=math.min(sPos*math.abs(((math.abs(RStickY)-.1)/(.9)))*-75,30)
					end
				else
					CUp=0
				end
			else
				if CRot>look then
					CRot=math.max(look,CRot-20)
				elseif CRot<look then
					CRot=math.min(look,CRot+20)
				end
				CUp=0
			end
			if intcam then
				CBack=0
			else
				CBack=-180*ButtonR3
			end
			if intcam then
				cam.CameraSubject=player.Character.Humanoid
				cam.CameraType=Enum.CameraType.Scriptable
				cam.FieldOfView=70 + car.DriveSeat.Velocity.Magnitude/40
				player.CameraMaxZoomDistance=5
				local cf=car.Misc.ActualCam.Parts.Cam.CFrame
				if ButtonR3==1 then
					cf=car.Body.RCam.CFrame
				end
				cam.CoordinateFrame=cf*CFrame.Angles(0,math.rad(CRot+CBack),0)*CFrame.Angles(math.rad(CUp),0,0)
			else
				cam.CameraSubject=car.DriveSeat
				cam.FieldOfView=70
				if mode==0 then
					cam.CameraType=Enum.CameraType.Custom
					player.CameraMaxZoomDistance=400
					run:UnbindFromRenderStep("CamUpdate")
				else
					cam.CameraType = "Scriptable"
					local pspeed = math.min(1,car.DriveSeat.Velocity.Magnitude/500)
					local cc = car.DriveSeat.Position+Vector3.new(0,8+(pspeed*2),0)-((car.DriveSeat.CFrame*CFrame.Angles(math.rad(CUp),math.rad(CRot+CBack),0)).lookVector*17)+(car.DriveSeat.Velocity.Unit*-7*pspeed)
					cam.CoordinateFrame = CFrame.new(cc,car.DriveSeat.Position)
				end
			end
		end) then
			cam.FieldOfView=70
			cam.CameraSubject=player.Character.Humanoid
			cam.CameraType=Enum.CameraType.Custom
			player.CameraMaxZoomDistance=400
			run:UnbindFromRenderStep("CamUpdate")
		end
	end
	local function ModeChange()
		if GMode~=mode then
			mode=GMode
			run:BindToRenderStep("CamUpdate",Enum.RenderPriority.Camera.Value,CamUpdate)
		end
	end
	mouse.KeyDown:connect(function(key)
		if key=="" then
			look=50
		elseif key=="" then
			if intcam then
				look=-160
			else
				look=-180
			end
		elseif key=="" then
			look=-50
		elseif key=="v" then
			run:UnbindFromRenderStep("CamUpdate")
			intcam=not intcam
			run:BindToRenderStep("CamUpdate",Enum.RenderPriority.Camera.Value,CamUpdate)
		end
	end)
	mouse.KeyUp:connect(function(key)
		if key=="" and look==50 then
			look=0
		elseif key=="" and (look==-160 or look==-180) then
			look=0
		elseif key=="" and look==-50 then
			look=0
		end
	end)
	run:BindToRenderStep("CMChange",Enum.RenderPriority.Camera.Value,ModeChange)
	table.insert(Binded,"CamUpdate")
	table.insert(Binded,"CMChange")
end
Camera()

mouse.KeyDown:connect(function(key)
	if key=="" then
		if GMode>=1 then
			GMode=0
		else
			GMode=GMode+1
		end
		if GMode==1 then
			Controller=true
		else
			Controller=false
		end
	end
end)



