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


 
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")
				Camera.FieldOfView = 45
	        elseif cam == ("lockplr") then
				Camera.CameraSubject = carSeat
				Camera.CameraType = ("Custom")
				cam = ("car")
				Camera.FieldOfView = 70
	        end
		elseif key == "[" then -- volume down
			if carSeat.Parent.Body.MP.Sound.Volume >= 0 then
				handler:FireServer('volumedown', true)
				carSeat.Parent.Body.Dash.Screen.G.Main.Icon.Vol.Text = ("Vol: "..carSeat.Parent.Body.MP.Sound.Volume)
			end
		elseif key == "]" then -- volume up
			if carSeat.Parent.Body.MP.Sound.Volume <= 10 then
				handler:FireServer('volumeup', true)
				carSeat.Parent.Body.Dash.Screen.G.Main.Icon.Vol.Text = ("Vol: "..carSeat.Parent.Body.MP.Sound.Volume)
			end	
		elseif key == "j" then -- volume up
			if scr == false then
				scr = true
				script.Parent.Infotainment:TweenPosition(UDim2.new(0.7, 0, 0.3, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,.6,true)
			else scr = false
				script.Parent.Infotainment:TweenPosition(UDim2.new(1, 0, 0.3, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,.6,true)
			end
	end
end)

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

HUB.Eco.MouseButton1Click:connect(function() --Hide tracker names
	handler:FireServer('Eco')
end)

HUB.Comfort.MouseButton1Click:connect(function() --Hide tracker names
	handler:FireServer('Comfort')
end)

HUB.Sport.MouseButton1Click:connect(function() --Hide tracker names
	handler:FireServer('Sport')
end)

winfob.mg.Play.MouseButton1Click:connect(function() --Play the next song
	handler:FireServer('updateSong', winfob.mg.Input.Text)
	carSeat.Parent.Body.Dash.Screen.G.Main.Icon.ID.Text = (winfob.mg.Input.Text)
end)

winfob.mg.Stop.MouseButton1Click:connect(function() --Play the next song
	handler:FireServer('pauseSong')
	carSeat.Parent.Body.Dash.Screen.G.Main.Icon.ID.Text = ""
end)

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

game.Lighting.Changed:connect(function(prop)
	if prop == "TimeOfDay" then
	handler:FireServer('TimeUpdate')
	end
end)

if game.Workspace.FilteringEnabled == true then
	handler:FireServer('feON')
elseif game.Workspace.FilteringEnabled == false then
	handler:FireServer('feOFF')
end

carSeat.LI.Changed:connect(function()
	if carSeat.LI.Value == true then
		carSeat.Parent.Body.Dash.DashSc.G.Left.Visible = true
		script.Parent.HUB.Left.Visible = true
	else
		carSeat.Parent.Body.Dash.DashSc.G.Left.Visible = false
		script.Parent.HUB.Left.Visible = false
	end
end)

carSeat.RI.Changed:connect(function()
	if carSeat.RI.Value == true then
		carSeat.Parent.Body.Dash.DashSc.G.Right.Visible = true
		script.Parent.HUB.Right.Visible = true
	else
		carSeat.Parent.Body.Dash.DashSc.G.Right.Visible = false
		script.Parent.HUB.Right.Visible = 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


while wait() do
	carSeat.Parent.Body.Dash.DashSc.G.Speed.Text = (math.floor(carSeat.Velocity.magnitude*((10/12) * (60/88))))
	carSeat.Parent.Body.Dash.DashSc.G.Time.Text = game.Lighting.TimeOfDay
end