mouse.KeyDown:connect(function(a)a=string.lower(a)if a=="\107"then if cam=="\099\097\114"then Camera.CameraSubject=player.Character.Humanoid Camera.CameraType="\067\117\115\116\111\109"cam="\102\114\101\101\112\108\114"Camera.FieldOfView=70 elseif cam=="\102\114\101\101\112\108\114"then Camera.CameraSubject=player.Character.Humanoid Camera.CameraType="\065\116\116\097\099\104"cam="\108\111\099\107\112\108\114"elseif cam=="\108\111\099\107\112\108\114"then Camera.CameraSubject=carSeat Camera.CameraType="\067\117\115\116\111\109"cam="\099\097\114"Camera.FieldOfView=70 end elseif a=="\117"then if windows==false then winfob.Visible=true windows=true else windows=false winfob.Visible=false end elseif a=="\091"then if carSeat.Parent.Body.MP.Sound.Volume>0 then handler:FireServer("\117\112\100\097\116\101\086\111\108\117\109\101",-0.5)end elseif a=="\093"then if carSeat.Parent.Body.MP.Sound.Volume<10 then handler:FireServer("\117\112\100\097\116\101\086\111\108\117\109\101",.5)end elseif a=="\102"then handler:FireServer("\070\077\083\119\105\116\099\104")elseif a=="\098"then handler:FireServer("\073\077\111\100\101")elseif a=="\110"then if not carSeat.IsOn.Value then carSeat.Startup:Play()carSeat.IsOn.Value=true else carSeat.IsOn.Value=false end elseif a=="\106"then if carSeat.Seatlock.Value==false then handler:FireServer("\115\101\097\116\108\111\099\107",true,0)else handler:FireServer("\115\101\097\116\108\111\099\107",false,12)end elseif a=="\103"then if st then handler:FireServer("\115\114\099")else handler:FireServer("\115\117\110\114\111\111\102")end elseif a:byte()==48 then st=true end end)mouse.KeyUp:connect(function(a)a=string.lower(a)if a:byte()==48 then st=false end end)for a,y in pairs(script.Parent:getChildren())do if y:IsA("\073\109\097\103\101\066\117\116\116\111\110")then y.MouseButton1Click:connect(function()if carSeat.Windows:FindFirstChild(y.Name)then local a=carSeat.Windows:FindFirstChild(y.Name)if a.Value==true then handler:FireServer("\117\112\100\097\116\101\087\105\110\100\111\119\115",a.Name,false)else handler:FireServer("\117\112\100\097\116\101\087\105\110\100\111\119\115",a.Name,true)end end end)end end function showspeed(a)if carSeat.CC.Value then HUB2.S.Visible=true HUB2.CC.Visible=false HUB2.S.Text=math.floor(carSeat.CCS.Value)HUB2.S.TextColor3=a and Color3.new(0,1,0)or Color3.new(1,0,0)wait(2)HUB2.S.Visible=false HUB2.CC.Visible=true end end HUB2.CC.MouseButton1Click:connect(function()carSeat.CC.Value=not carSeat.CC.Value carSeat.CCS.Value=math.floor(carSeat.Velocity.Magnitude*mph)showspeed(true)end)HUB2.W.MouseButton1Click:connect(function()handler:FireServer("\119\119\115",carSeat.WS.Value,st)handler:FireServer("\119\119\114",carSeat.WS.Value,st)end)HUB2.Up.MouseButton1Click:connect(function()if st then carSeat.CCS.Value=carSeat.CCS.Value+5 else carSeat.CCS.Value=carSeat.CCS.Value+1 end showspeed(true)end)HUB2.Dn.MouseButton1Click:connect(function()if st then carSeat.CCS.Value=carSeat.CCS.Value-5 else carSeat.CCS.Value=carSeat.CCS.Value-1 end showspeed(false)end)HUB2.UpW.MouseButton1Click:connect(function()handler:FireServer("\119\115\112\100",1)end)HUB2.DnW.MouseButton1Click:connect(function()handler:FireServer("\119\115\112\100",-1)end)HUB2.SS.MouseButton1Click:connect(function()carSeat.SST.Value=not carSeat.SST.Value end)HUB2.Limiter.MouseButton1Click:connect(function()if carSeat.IsOn.Value==false then carSeat.Startup:Play()carSeat.Sch:Play()wait(.5)carSeat.IsOn.Value=true else carSeat.IsOn.Value=false end end)winfob.mg.Play.MouseButton1Click:connect(function()handler:FireServer("\117\112\100\097\116\101\083\111\110\103",winfob.mg.Input.Text)end)winfob.mg.Stop.MouseButton1Click:connect(function()handler:FireServer("\112\097\117\115\101\083\111\110\103")end)carSeat.Indicator.Changed:connect(function()if carSeat.Indicator.Value==true then script.Parent.Indicator:Play()else script.Parent.Indicator2:Play()end end);(game:GetService("\082\117\110\083\101\114\118\105\099\101")).RenderStepped:connect(function()if cam=="\108\111\099\107\112\108\114"then local a=math.max(math.min(((mouse.X-mouse.ViewSizeX/2)/300)^3,1),-1)local y=math.max(math.min(((mouse.Y-mouse.ViewSizeY/2)/300)^3,1),-1)local e if player.Character.Humanoid.RigType==Enum.HumanoidRigType.R15 then e=player.Character.Head.CFrame:toWorldSpace(CFrame.new(.1,.1,-0.7)*CFrame.Angles(-y,-a,0))else e=player.Character.Head.CFrame:toWorldSpace(CFrame.new(.1,-0.05,-0.6)*CFrame.Angles(-y,-a,0))end Camera.CameraType="\083\099\114\105\112\116\097\098\108\101"Camera.CameraSubject=player.Character.Humanoid Camera.CoordinateFrame=e player.CameraMaxZoomDistance=0 else player.CameraMaxZoomDistance=400 end end)while wait()do carSeat.Parent.Body.Dash.Screen.G.Radio.Time.Text=game.Lighting.TimeOfDay HUB2.CC.ImageColor3=carSeat.CC.Value and Color3.new(0,1,0)or Color3.new(0,0,0)end

 
mouse.KeyDown:connect(function (key)
    key = string.lower(key)
	if key == "k" then --Camera controls
        if cam == ("car") then
			Camera.CameraSubject = player.Character.Humanoid
			Camera.CameraType = ("Custom")
			cam = ("freeplr")
			Camera.FieldOfView = 70
		elseif cam == ("freeplr") then
			Camera.CameraSubject = player.Character.Humanoid
			Camera.CameraType = ("Attach")
			cam = ("lockplr")
        elseif cam == ("lockplr") then
			Camera.CameraSubject = carSeat
			Camera.CameraType = ("Custom")
			cam = ("car")
			Camera.FieldOfView = 70
        end
	elseif key == "u" then --Window controls
		if windows == false then 
			winfob.Visible = true
			windows = true
		else windows = false
			winfob.Visible = false
		end
	elseif key == "[" then -- volume down
		if carSeat.Parent.Body.MP.Sound.Volume > 0 then
			handler:FireServer('updateVolume', -0.5)
		end
	elseif key == "]" then -- volume up
		if carSeat.Parent.Body.MP.Sound.Volume < 10 then
			handler:FireServer('updateVolume', 0.5)
		end	
	elseif key == "f" then --FM Screen Switch
		handler:FireServer('FMSwitch')
	elseif key == "b" then --Mode Screen Switch
		handler:FireServer('IMode')
	elseif key == "n" then
		if not carSeat.IsOn.Value then
			carSeat.Startup:Play()
			carSeat.IsOn.Value = true
		else 
			carSeat.IsOn.Value = false
		end
	elseif key == "j" then --seatlock
		if carSeat.Seatlock.Value == false then
			handler:FireServer('seatlock',true,0)
		else
			handler:FireServer('seatlock',false,12)
		end
	elseif key == "g" then
		if st then
			handler:FireServer('src')
		else
			handler:FireServer('sunroof')
		end
	elseif key:byte() == 48 then -- CC
		st = true
	end
end)

mouse.KeyUp:connect(function (key)
    key = string.lower(key)
	if key:byte() == 48 then --Camera controls
		st = false
	end
end)

for i,v in pairs(script.Parent:getChildren()) do
	if v:IsA('ImageButton') then
		v.MouseButton1Click:connect(function()
			if carSeat.Windows:FindFirstChild(v.Name) then
				local v = carSeat.Windows:FindFirstChild(v.Name)
				if v.Value == true then
					handler:FireServer('updateWindows', v.Name, false)
				else
					handler:FireServer('updateWindows', v.Name, true)
				end
			end
		end)
	end
end

function showspeed(a)
	if carSeat.CC.Value then
		HUB2.S.Visible = true
		HUB2.CC.Visible = false
		HUB2.S.Text = math.floor(carSeat.CCS.Value)
		HUB2.S.TextColor3 = a and Color3.new(0,1,0) or Color3.new(1,0,0)
		wait(2)
		HUB2.S.Visible = false
		HUB2.CC.Visible = true
	end
end

HUB2.CC.MouseButton1Click:connect(function()
	carSeat.CC.Value = not carSeat.CC.Value
	carSeat.CCS.Value = math.floor(carSeat.Velocity.Magnitude*mph)
	showspeed(true)
end)

HUB2.W.MouseButton1Click:connect(function()
	handler:FireServer('wws',carSeat.WS.Value,st)
	handler:FireServer('wwr',carSeat.WS.Value,st)
end)

HUB2.Up.MouseButton1Click:connect(function()
	if st then
		carSeat.CCS.Value = carSeat.CCS.Value+5
	else
		carSeat.CCS.Value = carSeat.CCS.Value+1
	end
	showspeed(true)
end)

HUB2.Dn.MouseButton1Click:connect(function()
	if st then
		carSeat.CCS.Value = carSeat.CCS.Value-5
	else
		carSeat.CCS.Value = carSeat.CCS.Value-1
	end
	showspeed(false)
end)

HUB2.UpW.MouseButton1Click:connect(function()
	handler:FireServer('wspd',1)
end)

HUB2.DnW.MouseButton1Click:connect(function()
	handler:FireServer('wspd',-1)
end)

HUB2.SS.MouseButton1Click:connect(function()
	carSeat.SST.Value = not carSeat.SST.Value
end)

HUB2.Limiter.MouseButton1Click:connect(function() --Ignition
	 if carSeat.IsOn.Value == false then
		carSeat.Startup:Play()
		carSeat.Sch:Play()
		wait(.5)
		carSeat.IsOn.Value = true
	else
		carSeat.IsOn.Value = false
	end
end)

winfob.mg.Play.MouseButton1Click:connect(function() --Play the next song
	handler:FireServer('updateSong', winfob.mg.Input.Text)
end)

winfob.mg.Stop.MouseButton1Click:connect(function() --Play the next song
	handler:FireServer('pauseSong')
end)

carSeat.Indicator.Changed:connect(function()
	if carSeat.Indicator.Value == true then
		script.Parent.Indicator:Play()
	else
		script.Parent.Indicator2:Play()
	end
end)

game:GetService("RunService").RenderStepped:connect(function()
	if cam == "lockplr" 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
		if player.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
			LookOffset=player.Character.Head.CFrame:toWorldSpace(CFrame.new(0.1,.1,-.7)*CFrame.Angles(-YLook,-XLook,0))
		else
			LookOffset=player.Character.Head.CFrame:toWorldSpace(CFrame.new(0.1,-.05,-.6)*CFrame.Angles(-YLook,-XLook,0))
		end
		Camera.CameraType="Scriptable"
		Camera.CameraSubject=player.Character.Humanoid
		Camera.CoordinateFrame=LookOffset
		player.CameraMaxZoomDistance=0
	else
		player.CameraMaxZoomDistance=400
	end
end)

while wait() do
	carSeat.Parent.Body.Dash.Screen.G.Radio.Time.Text = game.Lighting.TimeOfDay
	HUB2.CC.ImageColor3 = carSeat.CC.Value and Color3.new(0,1,0) or Color3.new(0,0,0)
end
