local TweenService = game:GetService("TweenService")
local isTardisPowered = script["Data Link"].Value.isTardisPowered
local timeout = false

local tweeningInfo = TweenInfo.new(.7, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local properties = { CFrame = CFrame.new(-1.5023663, 7.0893445, 58.3542709, 0.984808147, -3.66869699e-08, -0.173646823, -0.0577740073, 0.943029344, -0.327655584, 0.163754016, 0.332710117, 0.928702831); }
local activate = TweenService:Create(script.Parent.Main, tweeningInfo, properties)

tweeningInfo = TweenInfo.new(.7, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
properties = { CFrame = CFrame.new(-1.50233305, 7.0893302, 58.3543015, -0.342019916, 1.12122891e-07, -0.939692736, -0.312644899, 0.943029344, 0.113793463, 0.886157751, 0.332709789, -0.32253474); }
local deactivate = TweenService:Create(script.Parent.Main, tweeningInfo, properties)

local leds = {}
for _, part in pairs(script.Parent.Parent:GetChildren()) do
	if part.Name == string.match(part.Name, '^LED.*$') then
		print(part.Name)
		leds[tonumber(string.match(part.Name, '%d'))] = part
	end
end

local used = function()
	if timeout == false then
		timeout = true
		if isTardisPowered.Value == true then
			deactivate:Play()
			isTardisPowered.Value = false

			for i = 1, 7, 1 do
				leds[i].Material = Enum.Material.SmoothPlastic
				wait(.1)
			end

		else
			activate:Play()
			isTardisPowered.Value = true

			for i = 7, 1, -1 do
				leds[i].Material = Enum.Material.Neon
				wait(.1)
			end
		end
		wait(7)
		timeout = false
	end
end

script.Parent.Use.MouseClick:Connect(used)
