-------------------------

 
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 == "n" then --Mode Screen Switch
		handler:FireServer('IMode')
	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 --seatlock
		handler:FireServer('sunroof')
	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)