-- server side setup

local Pcolors = {{255, 255, 255}, {255, 180, 161}, {226, 220, 188}}
local Lcolors = {{184, 191, 191}, {184, 191, 191}, {184, 191, 191}}

local INDcolor = {255, 152, 92}
local plactive = false
local prevChild

F.Setup = function(light_type, popups, tb, fog_color)
	event.IndicatorsAfterLeave.Disabled = true
	for idx, child in pairs(lights.Brake:GetChildren()) do
		if child.Name == "L" and #child:GetChildren() < 1  then
			local spot = Instance.new("SpotLight", child)
			spot.Name = "L"
			spot.Brightness = 0
			spot.Range = 0
			spot.Face = Enum.NormalId.Back
			spot.Color = Color3.fromRGB(254, 29, 44)
			spot.Shadows = true
		elseif child.Name == "LN" then
			if child:IsA("MeshPart") then
				child.TextureID = ""
			end
			child.Material = Enum.Material.Neon
			child.Color = Color3.fromRGB(254, 29, 44)
			child.Transparency = 1					
		end	 
	end
	
	for idx, child in pairs(lights.Rear:GetChildren()) do
		if child.Name == "L" and #child:GetChildren() < 1 then
			local spot = Instance.new("SpotLight", child)
			spot.Name = "L"
			spot.Brightness = 0
			spot.Range = 0
			spot.Face = Enum.NormalId.Back
			spot.Color = Color3.fromRGB(255, 62, 65)
			spot.Shadows = true
		elseif child.Name == "LN" then
			if child:IsA("MeshPart") then
				child.TextureID = ""
			end
			child.Material = Enum.Material.Neon
			child.Color = Color3.fromRGB(255, 62, 65)
			child.Transparency = 1				
		end	 
	end
	
	for idx, child in pairs(lights.Reverse:GetChildren()) do
		if child.Name == "L" and #child:GetChildren() < 1 then		
			local spot = Instance.new("SpotLight", child)
			spot.Name = "L"
			spot.Brightness = 0
			spot.Range = 0
			spot.Face = Enum.NormalId.Back
			spot.Color = Color3.fromRGB(255, 255, 255)
			spot.Shadows = true
		elseif child.Name == "LN" then
			if child:IsA("MeshPart") then
				child.TextureID = ""
			end
			child.Material = Enum.Material.Neon
			child.Color = Color3.fromRGB(255, 255, 255)
			child.Transparency = 1				
		end	 
	end
	
	for idx, child in pairs(lights.LeftInd:GetDescendants()) do
		if child.Name == "L" and child.Parent.Name == "Front" and #child:GetChildren() < 1 then
			local spot = Instance.new("SpotLight", child)
			spot.Name = "L"
			spot.Brightness = 0
			spot.Range = 0
			spot.Face = Enum.NormalId.Front
			spot.Color = Color3.fromRGB(INDcolor[1], INDcolor[2], INDcolor[3])
			spot.Shadows = true
		elseif child.Name == "L" and child.Parent.Name == "Rear" and #child:GetChildren() < 1 then			
			local spot = Instance.new("SpotLight", child)
			spot.Name = "L"
			spot.Brightness = 0
			spot.Range = 0
			spot.Face = Enum.NormalId.Back
			spot.Color = Color3.fromRGB(INDcolor[1], INDcolor[2], INDcolor[3])	
			spot.Shadows = true
		elseif child.Name == "L" and child.Parent.Name == "Side" and #child:GetChildren() < 1 then
			local spot = Instance.new("SpotLight", child)
			spot.Name = "L"
			spot.Brightness = 0
			spot.Range = 0
			spot.Face = Enum.NormalId.Left
			spot.Color = Color3.fromRGB(INDcolor[1], INDcolor[2], INDcolor[3])
			spot.Shadows = true
		elseif child.Name == "LN" then
			if child:IsA("MeshPart") then
				child.TextureID = ""
			end
			child.Material = Enum.Material.Neon
			child.Color = Color3.fromRGB(INDcolor[1], INDcolor[2], INDcolor[3])
			child.Transparency = 1							
		elseif string.sub(child.Name, 1, 2) == "SI" then
			if child:IsA("MeshPart") then
				child.TextureID = ""
			end
			child.Material = Enum.Material.Neon
			child.Color = Color3.fromRGB(INDcolor[1], INDcolor[2], INDcolor[3])
			child.Transparency = 1	
		end	 
	end
	
	for idx, child in pairs(lights.RightInd:GetDescendants()) do
		if child.Name == "L" and child.Parent.Name == "Front" and #child:GetChildren() < 1 then
			local spot = Instance.new("SpotLight", child)
			spot.Name = "L"
			spot.Brightness = 0
			spot.Range = 0
			spot.Face = Enum.NormalId.Front
			spot.Color = Color3.fromRGB(INDcolor[1], INDcolor[2], INDcolor[3])
			spot.Shadows = true
		elseif child.Name == "L" and child.Parent.Name == "Rear" and #child:GetChildren() < 1 then			
			local spot = Instance.new("SpotLight", child)
			spot.Name = "L"
			spot.Brightness = 0
			spot.Range = 0
			spot.Face = Enum.NormalId.Back
			spot.Color = Color3.fromRGB(INDcolor[1], INDcolor[2], INDcolor[3])
			spot.Shadows = true
		elseif child.Name == "L" and child.Parent.Name == "Side" and #child:GetChildren() < 1 then
			local spot = Instance.new("SpotLight", child)
			spot.Name = "L"
			spot.Brightness = 0
			spot.Range = 0
			spot.Face = Enum.NormalId.Right
			spot.Color = Color3.fromRGB(INDcolor[1], INDcolor[2], INDcolor[3])
			spot.Shadows = true
		elseif child.Name == "LN" then
			if child:IsA("MeshPart") then
				child.TextureID = ""
			end
			child.Material = Enum.Material.Neon
			child.Color = Color3.fromRGB(INDcolor[1], INDcolor[2], INDcolor[3])
			child.Transparency = 1	
		elseif string.sub(child.Name, 1, 2) == "SI" then
			if child:IsA("MeshPart") then
				child.TextureID = ""
			end
			child.Material = Enum.Material.Neon
			child.Color = Color3.fromRGB(INDcolor[1], INDcolor[2], INDcolor[3])
			child.Transparency = 1		
		end	
	end	
	
	for idx, child in pairs(tb) do
		child.ImageTransparency = 1
	end
	
	if not popups then
		if light_type == "Pure White" then
			for idx, child in pairs(lights.Headlights:GetDescendants()) do
				if child.Name == "L" and #child:GetChildren() < 1 then		
					local spot = Instance.new("SpotLight", child)
					spot.Name = "L"
					spot.Brightness = 0
					spot.Range = 0
					spot.Face = Enum.NormalId.Front
					spot.Color = Color3.fromRGB(Lcolors[1][1], Lcolors[1][2], Lcolors[1][3])
					spot.Shadows = true
				elseif child.Name == "LN" then
					if child:IsA("MeshPart") then
						child.TextureID = ""
					end
					child.Material = Enum.Material.Neon
					child.Color = Color3.fromRGB(Pcolors[1][1], Pcolors[1][2], Pcolors[1][3])
					child.Transparency = 1					
				end	 
			end
		elseif light_type == "OEM White" then
			for idx, child in pairs(lights.Headlights:GetDescendants()) do
				if child.Name == "L" and #child:GetChildren() < 1 then
					local spot = Instance.new("SpotLight", child)
					spot.Name = "L"
					spot.Brightness = 0
					spot.Range = 0
					spot.Face = Enum.NormalId.Front
					spot.Color = Color3.fromRGB(Lcolors[2][1], Lcolors[2][2], Lcolors[2][3])
					spot.Shadows = true
				elseif child.Name == "LN" then
					if child:IsA("MeshPart") then
						child.TextureID = ""
					end
					child.Material = Enum.Material.Neon
					child.Color = Color3.fromRGB(Pcolors[2][1], Pcolors[2][2], Pcolors[2][3])
					child.Transparency = 1					
				end	 
			end		
		elseif light_type == "Xenon" then
			for idx, child in pairs(lights.Headlights:GetDescendants()) do
				if child.Name == "L" and #child:GetChildren() < 1 then
					local spot = Instance.new("SpotLight", child)
					spot.Name = "L"
					spot.Brightness = 0
					spot.Range = 0
					spot.Face = Enum.NormalId.Front
					spot.Color = Color3.fromRGB(Lcolors[3][1], Lcolors[3][2], Lcolors[3][3])
					spot.Shadows = true
				elseif child.Name == "LN" then
					if child:IsA("MeshPart") then
						child.TextureID = ""
					end
					child.Material = Enum.Material.Neon
					child.Color = Color3.fromRGB(Pcolors[3][1], Pcolors[3][2], Pcolors[3][3])
					child.Transparency = 1					
				end	 
			end		
		end
	else
		if light_type == "Pure White" then
			for idx, child in pairs(PHeadlights.Parts.Headlights:GetChildren()) do
				if child.Name == "L" and #child:GetChildren() < 1 then		
					local spot = Instance.new("SpotLight", child)
					spot.Name = "L"
					spot.Brightness = 0
					spot.Range = 0
					spot.Face = Enum.NormalId.Front
					spot.Color = Color3.fromRGB(Lcolors[1][1], Lcolors[1][2], Lcolors[1][3])
					spot.Shadows = true
				elseif child.Name == "LN" then
					if child:IsA("MeshPart") then
						child.TextureID = ""
					end
					child.Material = Enum.Material.Neon
					child.Color = Color3.fromRGB(Pcolors[1][1], Pcolors[1][2], Pcolors[1][3])
					child.Transparency = 1					
				end	 
			end
		elseif light_type == "OEM White" then
			for idx, child in pairs(PHeadlights.Parts.Headlights:GetChildren()) do
				if child.Name == "L" and #child:GetChildren() < 1 then
					local spot = Instance.new("SpotLight", child)
					spot.Name = "L"
					spot.Brightness = 0
					spot.Range = 0
					spot.Face = Enum.NormalId.Front
					spot.Color = Color3.fromRGB(Lcolors[2][1], Lcolors[2][2], Lcolors[2][3])
					spot.Shadows = true
				elseif child.Name == "LN" then
					if child:IsA("MeshPart") then
						child.TextureID = ""
					end
					child.Material = Enum.Material.Neon
					child.Color = Color3.fromRGB(Pcolors[2][1], Pcolors[2][2], Pcolors[2][3])
					child.Transparency = 1					
				end	 
			end		
		elseif light_type == "Xenon" then
			for idx, child in pairs(PHeadlights.Parts.Headlights:GetChildren()) do
				if child.Name == "L" and #child:GetChildren() < 1 then
					local spot = Instance.new("SpotLight", child)
					spot.Name = "L"
					spot.Brightness = 0
					spot.Range = 0
					spot.Face = Enum.NormalId.Front
					spot.Color = Color3.fromRGB(Lcolors[3][1], Lcolors[3][2], Lcolors[3][3])
					spot.Shadows = true
				elseif child.Name == "LN" then
					if child:IsA("MeshPart") then
						child.TextureID = ""
					end
					child.Material = Enum.Material.Neon
					child.Color = Color3.fromRGB(Pcolors[3][1], Pcolors[3][2], Pcolors[3][3])
					child.Transparency = 1					
				end	 
			end		
		end		
	end
	for idx, child in pairs(lights.Fog:GetChildren()) do
		if child.Name == "L" then
			local spot = Instance.new("SpotLight", child)
			spot.Name = "L"
			spot.Brightness = 0
			spot.Range = 0
			spot.Face = Enum.NormalId.Front
			spot.Color = fog_color
			spot.Shadows = true
		elseif child.Name == "LN" then
			if child:IsA("MeshPart") then
				child.TextureID = ""
			end
			child.Material = Enum.Material.Neon
			child.Color = fog_color
			child.Transparency = 1	
		end	
	end
	print("EpicLights Version 2 // Setup completed!")
end