--LIGHTS BUTTONS
for _,i in pairs(lights:GetChildren()) do
	if i:IsA("ImageButton") and i.Name ~= "header" then
		if string.match(i.Name,"%l+") == "td" then
			i.MouseButton1Click:connect(function()
				script.Parent.lighty.Value = tonumber(string.match(i.Name,"%d"))
				if script.Parent.lighty.Value == 0 then
					lights.td0.Image = imgassets.offon
					lights.td1.Image = imgassets.hazardoff
					lights.td2.Image = imgassets.leftyoff
					lights.td3.Image = imgassets.rightyoff
					lights.td4.Image = imgassets.outoff
				elseif script.Parent.lighty.Value == 1 then
					lights.td0.Image = imgassets.offoff
					lights.td1.Image = imgassets.hazardon
					lights.td2.Image = imgassets.leftyoff
					lights.td3.Image = imgassets.rightyoff
					lights.td4.Image = imgassets.outoff
				elseif script.Parent.lighty.Value == 2 then
					lights.td0.Image = imgassets.offoff
					lights.td1.Image = imgassets.hazardoff
					lights.td2.Image = imgassets.leftyon
					lights.td3.Image = imgassets.rightyoff
					lights.td4.Image = imgassets.outoff
				elseif script.Parent.lighty.Value == 3 then
					lights.td0.Image = imgassets.offoff
					lights.td1.Image = imgassets.hazardoff
					lights.td2.Image = imgassets.leftyoff
					lights.td3.Image = imgassets.rightyon
					lights.td4.Image = imgassets.outoff
				elseif script.Parent.lighty.Value == 4 then
					lights.td0.Image = imgassets.offoff
					lights.td1.Image = imgassets.hazardoff
					lights.td2.Image = imgassets.leftyoff
					lights.td3.Image = imgassets.rightyoff
					lights.td4.Image = imgassets.outon	
				end
			end)
		elseif string.match(i.Name,"%l+") == "fl" then
			i.MouseButton1Click:connect(function()
				script.Parent.flasher.Value = tonumber(string.match(i.Name,"%d"))
				if script.Parent.flasher.Value == 0 then
					lights.fl0.Image = imgassets.offon
					lights.fl1.Image = imgassets.slowoff
					lights.fl2.Image = imgassets.fastoff
					lights.fl3.Image = imgassets.x2off
					lights.fl4.Image = imgassets.x4off
				elseif script.Parent.flasher.Value == 1 then
					lights.fl0.Image = imgassets.offoff
					lights.fl1.Image = imgassets.slowon
					lights.fl2.Image = imgassets.fastoff
					lights.fl3.Image = imgassets.x2off
					lights.fl4.Image = imgassets.x4off
				elseif script.Parent.flasher.Value == 2 then
					lights.fl0.Image = imgassets.offoff
					lights.fl1.Image = imgassets.slowoff
					lights.fl2.Image = imgassets.faston
					lights.fl3.Image = imgassets.x2off
					lights.fl4.Image = imgassets.x4off
				elseif script.Parent.flasher.Value == 3 then
					lights.fl0.Image = imgassets.offoff
					lights.fl1.Image = imgassets.slowoff
					lights.fl2.Image = imgassets.fastoff
					lights.fl3.Image = imgassets.x2on
					lights.fl4.Image = imgassets.x4off
				elseif script.Parent.flasher.Value == 4 then
					lights.fl0.Image = imgassets.offoff
					lights.fl1.Image = imgassets.slowoff
					lights.fl2.Image = imgassets.fastoff
					lights.fl3.Image = imgassets.x2off
					lights.fl4.Image = imgassets.x4on			
				end
			end)
		end
	end
end

for _,i in pairs (siren:GetChildren()) do
	if i:IsA("ImageButton") and i.Name ~= "header" then
		if string.match(i.Name,"%l+") == "sr" then
			i.MouseButton1Click:connect(function()
				script.Parent.siren.Value = tonumber(string.match(i.Name,"%d"))
				if script.Parent.siren.Value == 0 then
					siren.sr0.Image = imgassets.offon
					siren.sr1.Image = imgassets.onoff
				elseif script.Parent.siren.Value == 1 then
					siren.sr0.Image = imgassets.offoff
					siren.sr1.Image = imgassets.onon
				end
			end)
		end
	end
end

for _,i in pairs (seats:GetChildren()) do
	if i:IsA("ImageButton") and i.Name ~= "header" then
		if string.match(i.Name,"%u%l+") == "Seat" then
			local a = seat:findFirstChild("Seat"..tonumber(string.match(i.Name,"%d")))
			if a.Value then
				i.Image = imgassets.lockon
			else
				i.Image = imgassets.lockoff
			end
			i.MouseButton1Click:connect(function()
				a.Value = not a.Value
				if a.Value then
					i.Image = imgassets.lockon
				else
					i.Image = imgassets.lockoff
				end
			end)
		end
	end
end
	
while true do
	wait(0.1)
	script.Parent.Speed.Text = ("Speed: "..math.floor(seat.Velocity.Magnitude/2))
end