local M=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local n=game:GetService("\082\117\110\083\101\114\118\105\099\101")local e=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local a=game.Players.LocalPlayer local F=a.Character or a.CharacterAdded:Wait()local Y=script.Parent.Parent:WaitForChild("\086\097\108\117\101\115")local t=script.Parent.Parent.Car.Value local P=t:WaitForChild("\068\114\105\118\101\083\101\097\116")local p=require(t:WaitForChild("\065-\067\104\097\115\115\105\115 \084\117\110\101"))local k=Y.Parent:WaitForChild("\073\115\079\110")local E=t:WaitForChild("\076\105\103\104\116\069\118\101\110\116")local B=script.Values.Left local U=script.Values.Right local w=script.Values.Hazard local q=script.Values.RunningLights local C=script.Values.Headlights local i=false local f=1 local H=false local x=false local m=false local A=false local R=false local Q=TweenInfo.new(.5,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0)local b=TweenInfo.new(Indicator_Flash_Rate/2.5,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0)function input(M,n)if not n then if M.KeyCode==Headlights then if C.Value==0 then C.Value=1 E:FireServer("\072\101\097\100\108\105\103\104\116\115",Low_Beam_Brightness,.2,48,x,Popups_Enabled,Headlight_Type,C.Value)E:FireServer("\082\101\097\114\076\105\103\104\116\115",Rear_Light_Type,Rear_Light_Brightness,.2,Trunk_Lights)if A then E:FireServer("\070\111\103\076\105\103\104\116\115",Fog_Light_Brightness,.02,Fog_Light_Type);(e:Create(script.Parent.FogLights,Q,{ImageTransparency=0})):Play()end;(e:Create(script.Parent.LowBeams,Q,{ImageTransparency=0})):Play()elseif C.Value==1 then C.Value=2 E:FireServer("\072\101\097\100\108\105\103\104\116\115",High_Beam_Brightness,.02,60,x,Popups_Enabled,Headlight_Type,C.Value);(e:Create(script.Parent.LowBeams,Q,{ImageTransparency=1})):Play();(e:Create(script.Parent.HighBeams,Q,{ImageTransparency=0})):Play()elseif C.Value==2 then C.Value=0 E:FireServer("\072\101\097\100\108\105\103\104\116\115",0,1,60,x,Popups_Enabled,Headlight_Type,C.Value)if not x then E:FireServer("\082\101\097\114\076\105\103\104\116\115",Rear_Light_Type,0,1,Trunk_Lights)end E:FireServer("\070\111\103\076\105\103\104\116\115",0,1,Fog_Light_Type);(e:Create(script.Parent.LowBeams,Q,{ImageTransparency=1})):Play();(e:Create(script.Parent.HighBeams,Q,{ImageTransparency=1})):Play();(e:Create(script.Parent.FogLights,Q,{ImageTransparency=1})):Play()end if Plate_Lights then if C.Value>=1 then E:FireServer("\080\108\097\116\101\076\105\103\104\116\115",true,Plate_Light_Type)else E:FireServer("\080\108\097\116\101\076\105\103\104\116\115",false,Plate_Light_Type)end end elseif M.KeyCode==Popups then if Popups_Enabled then if R==false then E:FireServer("\080\111\112\117\112\115",true,Popups_Enabled,Popup_Hinge_Angle)R=true else E:FireServer("\080\111\112\117\112\115",false,Popups_Enabled,Popup_Hinge_Angle)R=false end end elseif M.KeyCode==RunningLights then if Running_Light_Location~="\067\117\115\116\111\109 \068\082\076"then if not x then x=true;(e:Create(script.Parent.ParkLights,Q,{ImageTransparency=0})):Play()else x=false;(e:Create(script.Parent.ParkLights,Q,{ImageTransparency=1})):Play()end else if not m then m=true E:FireServer("\067\117\115\116\111\109\068\082\076",m,CustomDRL_Type);(e:Create(script.Parent.ParkLights,Q,{ImageTransparency=0})):Play()else m=false E:FireServer("\067\117\115\116\111\109\068\082\076",m,CustomDRL_Type);(e:Create(script.Parent.ParkLights,Q,{ImageTransparency=1})):Play()end end if C.Value==0 then E:FireServer("\072\101\097\100\108\105\103\104\116\115",0,1,60,x,Popups_Enabled,Headlight_Type,C.Value)if x or m then E:FireServer("\082\101\097\114\076\105\103\104\116\115",Rear_Light_Type,Rear_Light_Brightness,.2,Trunk_Lights)elseif not x or m then E:FireServer("\082\101\097\114\076\105\103\104\116\115",Rear_Light_Type,0,1,Trunk_Lights)end end elseif M.KeyCode==FogLights then if C.Value>0 then if not A then E:FireServer("\070\111\103\076\105\103\104\116\115",Fog_Light_Brightness,.02,Fog_Light_Type);(e:Create(script.Parent.FogLights,Q,{ImageTransparency=0})):Play()A=true else E:FireServer("\070\111\103\076\105\103\104\116\115",0,1,Fog_Light_Type);(e:Create(script.Parent.FogLights,Q,{ImageTransparency=1})):Play()A=false end else if not A then A=true else A=false end end elseif M.KeyCode==Flash then if not H then end elseif M.KeyCode==SignalLeft then if not B.Value then B.Value=true script.StackOn:Play()else B.Value=false script.StackOff:Play()end elseif M.KeyCode==SignalRight then if not U.Value then U.Value=true script.StackOn:Play()else U.Value=false script.StackOff:Play()end elseif M.KeyCode==Hazards then if not w.Value then w.Value=true else w.Value=false end end end end function autoLight()local M={16;18}local n={18,6.2}local a=game.Lighting:GetMinutesAfterMidnight()/60 if a>=M[1]and a<=M[2]then C.Value=0 x=true E:FireServer("\072\101\097\100\108\105\103\104\116\115",Low_Beam_Brightness,.2,48,x,Popups_Enabled,Headlight_Type,C.Value)E:FireServer("\082\101\097\114\076\105\103\104\116\115",Rear_Light_Type,Rear_Light_Brightness,.2,Trunk_Lights);(e:Create(script.Parent.ParkLights,Q,{ImageTransparency=0})):Play()elseif a>n[1]or a>=0 and a<=n[2]then C.Value=1 E:FireServer("\072\101\097\100\108\105\103\104\116\115",Low_Beam_Brightness,.02,48,x,Popups_Enabled,Headlight_Type,C.Value)E:FireServer("\082\101\097\114\076\105\103\104\116\115",Rear_Light_Type,Rear_Light_Brightness,.2,Trunk_Lights);(e:Create(script.Parent.LowBeams,Q,{ImageTransparency=0})):Play()else C.Value=0 E:FireServer("\072\101\097\100\108\105\103\104\116\115",0,1,0,x,Popups_Enabled,Headlight_Type,C.Value)E:FireServer("\082\101\097\114\076\105\103\104\116\115",Rear_Light_Type,0,1,Trunk_Lights)end end function brakes()if Y.Brake.Value>.01 then E:FireServer("\066\114\097\107\101\076\105\103\104\116\115",Rear_Light_Type,Brake_Light_Brightness,.02,Trunk_Lights)else E:FireServer("\066\114\097\107\101\076\105\103\104\116\115",Rear_Light_Type,0,1,Trunk_Lights)end end function reverse()if Y.Gear.Value==-1 then E:FireServer("\082\101\118\101\114\115\101",Reverse_Light_Type,Reverse_Light_Brightness,.02,Trunk_Lights)else E:FireServer("\082\101\118\101\114\115\101",Reverse_Light_Type,0,1,Trunk_Lights)end end function leavedriveseat()E:FireServer("\073\110\100\115\079\110\076\101\097\118\101",B.Value,U.Value,w.Value,Sequential_Indicators,Sequential_Segments,Indicator_Flash_Rate,Indicator_Type)end
--- DONT TOUCH ---

local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local Values = script.Parent.Parent:WaitForChild("Values")
local car = script.Parent.Parent.Car.Value
local DriveSeat = car:WaitForChild("DriveSeat")
local Tune = require(car:WaitForChild("A-Chassis Tune"))
local IsOn = Values.Parent:WaitForChild("IsOn")
local LightEvent = car:WaitForChild("LightEvent")

local LI = script.Values.Left
local RI = script.Values.Right
local H = script.Values.Hazard
local RL = script.Values.RunningLights
local HL = script.Values.Headlights

local setup = false
local current_seq_seg = 1
local flashing = false
local parklightActive = false
local drlActive = false
local fogActive = false
local popupsActive = false

local gui_tweeninfo = TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0)
local indgui_tweeninfo =
	TweenInfo.new(Indicator_Flash_Rate / 2.5, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0)

function input(key, gameprocessed)
	if not gameprocessed then
		if key.KeyCode == Headlights then
			if HL.Value == 0 then
				HL.Value = 1
				LightEvent:FireServer(
					"Headlights",
					Low_Beam_Brightness,
					0.2,
					48,
					parklightActive,
					Popups_Enabled,
					Headlight_Type,
					HL.Value
				)
				LightEvent:FireServer("RearLights", Rear_Light_Type, Rear_Light_Brightness, 0.2, Trunk_Lights)
				if fogActive then
					LightEvent:FireServer("FogLights", Fog_Light_Brightness, 0.02, Fog_Light_Type)
					TweenService:Create(script.Parent.FogLights, gui_tweeninfo, { ImageTransparency = 0 }):Play()
				end
				TweenService:Create(script.Parent.LowBeams, gui_tweeninfo, { ImageTransparency = 0 }):Play()
			elseif HL.Value == 1 then
				HL.Value = 2
				LightEvent:FireServer(
					"Headlights",
					High_Beam_Brightness,
					0.02,
					60,
					parklightActive,
					Popups_Enabled,
					Headlight_Type,
					HL.Value
				)
				TweenService:Create(script.Parent.LowBeams, gui_tweeninfo, { ImageTransparency = 1 }):Play()
				TweenService:Create(script.Parent.HighBeams, gui_tweeninfo, { ImageTransparency = 0 }):Play()
			elseif HL.Value == 2 then
				HL.Value = 0
				LightEvent:FireServer("Headlights", 0, 1, 60, parklightActive, Popups_Enabled, Headlight_Type, HL.Value)
				if not parklightActive then
					LightEvent:FireServer("RearLights", Rear_Light_Type, 0, 1, Trunk_Lights)
				end
				LightEvent:FireServer("FogLights", 0, 1, Fog_Light_Type)
				TweenService:Create(script.Parent.LowBeams, gui_tweeninfo, { ImageTransparency = 1 }):Play()
				TweenService:Create(script.Parent.HighBeams, gui_tweeninfo, { ImageTransparency = 1 }):Play()
				TweenService:Create(script.Parent.FogLights, gui_tweeninfo, { ImageTransparency = 1 }):Play()
			end
			if Plate_Lights then
				if HL.Value >= 1 then
					LightEvent:FireServer("PlateLights", true, Plate_Light_Type)
				else
					LightEvent:FireServer("PlateLights", false, Plate_Light_Type)
				end
			end
		elseif key.KeyCode == Popups then
			if Popups_Enabled then
				if popupsActive == false then
					LightEvent:FireServer("Popups", true, Popups_Enabled, Popup_Hinge_Angle)
					popupsActive = true
				else
					LightEvent:FireServer("Popups", false, Popups_Enabled, Popup_Hinge_Angle)
					popupsActive = false
				end
			end
		elseif key.KeyCode == RunningLights then
			if Running_Light_Location ~= "Custom DRL" then
				if not parklightActive then
					parklightActive = true
					TweenService:Create(script.Parent.ParkLights, gui_tweeninfo, { ImageTransparency = 0 }):Play()
				else
					parklightActive = false
					TweenService:Create(script.Parent.ParkLights, gui_tweeninfo, { ImageTransparency = 1 }):Play()
				end
			else
				if not drlActive then
					drlActive = true
					LightEvent:FireServer("CustomDRL", drlActive, CustomDRL_Type)
					TweenService:Create(script.Parent.ParkLights, gui_tweeninfo, { ImageTransparency = 0 }):Play()
				else
					drlActive = false
					LightEvent:FireServer("CustomDRL", drlActive, CustomDRL_Type)
					TweenService:Create(script.Parent.ParkLights, gui_tweeninfo, { ImageTransparency = 1 }):Play()
				end
			end
			if HL.Value == 0 then
				LightEvent:FireServer("Headlights", 0, 1, 60, parklightActive, Popups_Enabled, Headlight_Type, HL.Value)
				if parklightActive or drlActive then
					LightEvent:FireServer("RearLights", Rear_Light_Type, Rear_Light_Brightness, 0.2, Trunk_Lights)
				elseif not parklightActive or drlActive then
					LightEvent:FireServer("RearLights", Rear_Light_Type, 0, 1, Trunk_Lights)
				end
			end
		elseif key.KeyCode == FogLights then
			if HL.Value > 0 then
				if not fogActive then
					LightEvent:FireServer("FogLights", Fog_Light_Brightness, 0.02, Fog_Light_Type)
					TweenService:Create(script.Parent.FogLights, gui_tweeninfo, { ImageTransparency = 0 }):Play()
					fogActive = true
				else
					LightEvent:FireServer("FogLights", 0, 1, Fog_Light_Type)
					TweenService:Create(script.Parent.FogLights, gui_tweeninfo, { ImageTransparency = 1 }):Play()
					fogActive = false
				end
			else
				if not fogActive then
					fogActive = true
				else
					fogActive = false
				end
			end
		elseif key.KeyCode == Flash then
			if not flashing then
			end
		elseif key.KeyCode == SignalLeft then
			if not LI.Value then
				LI.Value = true
				script.StackOn:Play()
			else
				LI.Value = false
				script.StackOff:Play()
			end
		elseif key.KeyCode == SignalRight then
			if not RI.Value then
				RI.Value = true
				script.StackOn:Play()
			else
				RI.Value = false
				script.StackOff:Play()
			end
		elseif key.KeyCode == Hazards then
			if not H.Value then
				H.Value = true
			else
				H.Value = false
			end
		end
	end
end

function autoLight()
	local dusk = { 16, 18 }
	local night = { 18, 6.2 }
	local timenow = game.Lighting:GetMinutesAfterMidnight() / 60

	if timenow >= dusk[1] and timenow <= dusk[2] then
		HL.Value = 0
		parklightActive = true
		LightEvent:FireServer(
			"Headlights",
			Low_Beam_Brightness,
			0.2,
			48,
			parklightActive,
			Popups_Enabled,
			Headlight_Type,
			HL.Value
		)
		LightEvent:FireServer("RearLights", Rear_Light_Type, Rear_Light_Brightness, 0.2, Trunk_Lights)
		TweenService:Create(script.Parent.ParkLights, gui_tweeninfo, { ImageTransparency = 0 }):Play()
	elseif timenow > night[1] or (timenow >= 0 and timenow <= night[2]) then
		HL.Value = 1
		LightEvent:FireServer(
			"Headlights",
			Low_Beam_Brightness,
			0.02,
			48,
			parklightActive,
			Popups_Enabled,
			Headlight_Type,
			HL.Value
		)
		LightEvent:FireServer("RearLights", Rear_Light_Type, Rear_Light_Brightness, 0.2, Trunk_Lights)
		TweenService:Create(script.Parent.LowBeams, gui_tweeninfo, { ImageTransparency = 0 }):Play()
	else
		HL.Value = 0
		LightEvent:FireServer("Headlights", 0, 1, 0, parklightActive, Popups_Enabled, Headlight_Type, HL.Value)
		LightEvent:FireServer("RearLights", Rear_Light_Type, 0, 1, Trunk_Lights)
	end
end

function brakes()
	if Values.Brake.Value > 0.01 then
		LightEvent:FireServer("BrakeLights", Rear_Light_Type, Brake_Light_Brightness, 0.02, Trunk_Lights)
	else
		LightEvent:FireServer("BrakeLights", Rear_Light_Type, 0, 1, Trunk_Lights)
	end
end

function reverse()
	if Values.Gear.Value == -1 then
		LightEvent:FireServer("Reverse", Reverse_Light_Type, Reverse_Light_Brightness, 0.02, Trunk_Lights)
	else
		LightEvent:FireServer("Reverse", Reverse_Light_Type, 0, 1, Trunk_Lights)
	end
end

function leavedriveseat()
	LightEvent:FireServer(
		"IndsOnLeave",
		LI.Value,
		RI.Value,
		H.Value,
		Sequential_Indicators,
		Sequential_Segments,
		Indicator_Flash_Rate,
		Indicator_Type
	)
end
