--Put Brakes,Headlight,Highlight,Left,Reverse,and Right into Body. 
--Put this script into Plugins
-- Duplicate your lights, make it neon and put it inside G1 of the corrisponding model.
-- What it does is it enables a light inside the parts named Light and makes the part's transparency 0. 
-- When its off, it disables the Light and sets the transparency to 1

local FE = workspace.FilteringEnabled
local car = script.Parent.Car.Value
local _Tune = require(car["A-Chassis Tune"])

local body = car.Body

local event=car.SmeersLightsHandler

local dtapdleft=false

local uis=game:GetService("UserInputService")

uis.InputBegan:connect(function(input, gp)
	if not gp then
		if input.KeyCode==Enum.KeyCode.Z or input.KeyCode==Enum.KeyCode.DPadLeft then
			event:FireServer({["ToggleLeftBlink"]=true})
		elseif input.KeyCode==Enum.KeyCode.C or input.KeyCode==Enum.KeyCode.DPadRight then
			event:FireServer({["ToggleRightBlink"]=true})
		elseif input.KeyCode==Enum.KeyCode.V then
			event:FireServer({["ToggleStandlicht"]=true})
		elseif input.KeyCode==Enum.KeyCode.X then
			event:FireServer({["ToggleHazards"]=true})
		end
	end
end)

local Time, Activate, Blink, End = .2, 40, .1, 3
local CurrTime = 0 -- don't change this

car.DriveSeat.Changed:Connect(function(Change)
	if Change == "Throttle" then
		if car.DriveSeat.Throttle == -1 then
			event:FireServer({["EnableBrakes"]=true})
			if math.floor((10/12) * (60/88)*car.DriveSeat.Velocity.Magnitude) >= Activate then
				repeat if math.floor((10/12) * (60/88)*car.DriveSeat.Velocity.Magnitude) >= Activate then 
					if car.DriveSeat.Throttle == -1 then
					   CurrTime = CurrTime + .05
					else
				     CurrTime = 0
				      break 						
					end
			else
				CurrTime = 0
				break 
				 end
				wait(.05)
				 until CurrTime >= Time 
				 if CurrTime >= Time then
					CurrTime = 0
					if math.floor((10/12) * (60/88)*car.DriveSeat.Velocity.Magnitude) >= Activate then
					repeat	
				 if math.floor((10/12) * (60/88)*car.DriveSeat.Velocity.Magnitude) >= Activate or car.DriveSeat.Throttle == -1 then					
					event:FireServer({["EnableBrakes"]=true})
					wait(Blink)
					event:FireServer({["DisableBrakes"]=true})
					wait(Blink)	
					end
					until math.floor((10/12) * (60/88)*car.DriveSeat.Velocity.Magnitude) <= End or car.DriveSeat.Throttle ~= -1
					if math.floor((10/12) * (60/88)*car.DriveSeat.Velocity.Magnitude) <= End then
                       event:FireServer({["ToggleHazards"]=true})
					   event:FireServer({["EnableBrakes"]=true})						
					end
					end
				else
					CurrTime = 0
				end
			end
		else
			event:FireServer({["DisableBrakes"]=true})
		end
	end
end)

script.Parent.Values.Gear.Changed:connect(function()
	if script.Parent.Values.Gear.Value == -1 then
		event:FireServer({["ReverseOn"]=true})
	elseif script.Parent.Values.Gear.Value ~= -1 then
		event:FireServer({["ReverseOff"]=true})
	end
end)
