local dataLink = script["Data Link"].Value
local button = script.Parent.Parent.SingleSendActivate
local bulb = script.Parent.Parent.ActiveLED.Bulb
local bits = {}

for _, part in pairs(script.Parent.Parent:GetChildren()) do
	if part.Name == string.match(part.Name, '^Bit.*$') then
		table.insert(bits, part)
	end
end


script.Parent.Use.MouseClick:Connect(function()
	if dataLink.isDataSingleSendActive.Value == false then
		button.Position = Vector3.new(button.Position.X + 0.02, button.Position.Y - 0.065, button.Position.Z - 0.011)
		dataLink.isDataSingleSendActive.Value = true
		dataLink.singleSendFrequency.Value = 0
		for _, part in pairs(bits) do
			part.Bulb.Material = Enum.Material.Plastic
		end
		bulb.Color = Color3.fromRGB(0, 255, 0)

	elseif dataLink.isDataSingleSendActive.Value then
		button.Position = Vector3.new(button.Position.X - 0.02, button.Position.Y + 0.065, button.Position.Z + 0.011)
		dataLink.isDataSingleSendActive.Value = false
		dataLink.isDataSingleSendReverseActive.Value = false
		dataLink.isDataSingleListenAutoTravelActive.Value = false
		for _, part in pairs(bits) do
			part.Bulb.Material = Enum.Material.Plastic
		end
		bulb.Color = Color3.fromRGB(196, 40, 28)
	end
end)
