Cronometro
Key RequiredUniversal

Cronometro

Universal ScriptTonicostaTonicosta 648 views 328 executesUpdated Dec 12, 2025
Unrated
00
Lua Script•279 lines (8948 chars)
-- Delta Executor Timer Hub
-- Criado por solicitação

local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local CoreGui = game:GetService("CoreGui")

-- Proteção para não duplicar a UI se executar 2 vezes
if CoreGui:FindFirstChild("DeltaTimerHub") then
    CoreGui.DeltaTimerHub:Destroy()
end

-- --- CRIAÇÃO DA UI ---

local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "DeltaTimerHub"
ScreenGui.Parent = CoreGui
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling

-- Frame Principal
local MainFrame = Instance.new("Frame")
MainFrame.Name = "MainFrame"
MainFrame.Parent = ScreenGui
MainFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
MainFrame.Position = UDim2.new(0.5, -100, 0.3, 0) -- Centralizado
MainFrame.Size = UDim2.new(0, 220, 0, 160)
MainFrame.BorderSizePixel = 0

local UICorner = Instance.new("UICorner")
UICorner.CornerRadius = UDim.new(0, 12)
UICorner.Parent = MainFrame

-- Título e Barra Superior (Para Arrastar)
local TitleBar = Instance.new("TextLabel")
TitleBar.Name = "TitleBar"
TitleBar.Parent = MainFrame
TitleBar.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
TitleBar.BackgroundTransparency = 1
TitleBar.Size = UDim2.new(1, -40, 0, 30)
TitleBar.Position = UDim2.new(0, 10, 0, 0)
TitleBar.Font = Enum.Font.GothamBold
TitleBar.Text = "Cronômetro Hub"
TitleBar.TextColor3 = Color3.fromRGB(255, 255, 255)
TitleBar.TextSize = 14
TitleBar.TextXAlignment = Enum.TextXAlignment.Left

-- Botão Minimizar
local MinimizeBtn = Instance.new("TextButton")
MinimizeBtn.Name = "MinimizeBtn"
MinimizeBtn.Parent = MainFrame
MinimizeBtn.BackgroundColor3 = Color3.fromRGB(255, 80, 80)
MinimizeBtn.Position = UDim2.new(1, -30, 0, 5)
MinimizeBtn.Size = UDim2.new(0, 20, 0, 20)
MinimizeBtn.Font = Enum.Font.GothamBold
MinimizeBtn.Text = "-"
MinimizeBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
MinimizeBtn.TextSize = 14
MinimizeBtn.AutoButtonColor = false

local MiniCorner = Instance.new("UICorner")
MiniCorner.CornerRadius = UDim.new(1, 0) -- Redondo
MiniCorner.Parent = MinimizeBtn

-- Container dos Controles (Para sumir ao minimizar)
local ContentFrame = Instance.new("Frame")
ContentFrame.Name = "ContentFrame"
ContentFrame.Parent = MainFrame
ContentFrame.BackgroundTransparency = 1
ContentFrame.Position = UDim2.new(0, 0, 0, 30)
ContentFrame.Size = UDim2.new(1, 0, 1, -30)

-- Input de Tempo (00:00)
local TimeInput = Instance.new("TextBox")
TimeInput.Name = "TimeInput"
TimeInput.Parent = ContentFrame
TimeInput.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
TimeInput.Position = UDim2.new(0.5, -60, 0.1, 0)
TimeInput.Size = UDim2.new(0, 120, 0, 40)
TimeInput.Font = Enum.Font.GothamBold
TimeInput.PlaceholderText = "00:00"
TimeInput.Text = "00:00"
TimeInput.TextColor3 = Color3.fromRGB(0, 255, 150)
TimeInput.TextSize = 28
TimeInput.BorderSizePixel = 0

local InputCorner = Instance.new("UICorner")
InputCorner.CornerRadius = UDim.new(0, 8)
InputCorner.Parent = TimeInput

-- Botão START
local StartBtn = Instance.new("TextButton")
StartBtn.Name = "StartBtn"
StartBtn.Parent = ContentFrame
StartBtn.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
StartBtn.Position = UDim2.new(0.1, 0, 0.6, 0)
StartBtn.Size = UDim2.new(0, 50, 0, 30)
StartBtn.Font = Enum.Font.GothamBold
StartBtn.Text = "▶"
StartBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
StartBtn.TextSize = 18

local BtnCorner1 = Instance.new("UICorner")
BtnCorner1.CornerRadius = UDim.new(0, 6)
BtnCorner1.Parent = StartBtn

-- Botão PAUSE
local PauseBtn = Instance.new("TextButton")
PauseBtn.Name = "PauseBtn"
PauseBtn.Parent = ContentFrame
PauseBtn.BackgroundColor3 = Color3.fromRGB(200, 160, 0)
PauseBtn.Position = UDim2.new(0.5, -25, 0.6, 0)
PauseBtn.Size = UDim2.new(0, 50, 0, 30)
PauseBtn.Font = Enum.Font.GothamBold
PauseBtn.Text = "⏸"
PauseBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
PauseBtn.TextSize = 18

local BtnCorner2 = Instance.new("UICorner")
BtnCorner2.CornerRadius = UDim.new(0, 6)
BtnCorner2.Parent = PauseBtn

-- Botão STOP
local StopBtn = Instance.new("TextButton")
StopBtn.Name = "StopBtn"
StopBtn.Parent = ContentFrame
StopBtn.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
StopBtn.Position = UDim2.new(0.9, -50, 0.6, 0)
StopBtn.Size = UDim2.new(0, 50, 0, 30)
StopBtn.Font = Enum.Font.GothamBold
StopBtn.Text = "⏹"
StopBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
StopBtn.TextSize = 18

local BtnCorner3 = Instance.new("UICorner")
BtnCorner3.CornerRadius = UDim.new(0, 6)
BtnCorner3.Parent = StopBtn

-- --- LÓGICA DO ARRASTAR (DRAG) ---
local dragging, dragInput, dragStart, startPos

local function update(input)
    local delta = input.Position - dragStart
    MainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
end

MainFrame.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        dragging = true
        dragStart = input.Position
        startPos = MainFrame.Position
        
        input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then
                dragging = false
            end
        end)
    end
end)

MainFrame.InputChanged:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
        dragInput = input
    end
end)

UserInputService.InputChanged:Connect(function(input)
    if input == dragInput and dragging then
        update(input)
    end
end)

-- --- LÓGICA DO MINIMIZAR ---
local isMinimized = false
local originalSize = MainFrame.Size

MinimizeBtn.MouseButton1Click:Connect(function()
    if not isMinimized then
        -- Minimizar
        ContentFrame.Visible = false
        TweenService:Create(MainFrame, TweenInfo.new(0.3), {Size = UDim2.new(0, 220, 0, 30)}):Play()
        MinimizeBtn.Text = "+"
        MinimizeBtn.BackgroundColor3 = Color3.fromRGB(80, 255, 80)
        isMinimized = true
    else
        -- Maximizar
        TweenService:Create(MainFrame, TweenInfo.new(0.3), {Size = originalSize}):Play()
        task.wait(0.3)
        ContentFrame.Visible = true
        MinimizeBtn.Text = "-"
        MinimizeBtn.BackgroundColor3 = Color3.fromRGB(255, 80, 80)
        isMinimized = false
    end
end)

-- --- LÓGICA DO CRONÔMETRO ---
local timerRunning = false
local timerPaused = false
local totalSeconds = 0
local initialTime = 0 -- Para saber onde voltar quando clicar em STOP

-- Função auxiliar: Converte Texto "MM:SS" para Segundos
local function parseTime(str)
    local min, sec = str:match("(%d+):(%d+)")
    if min and sec then
        return (tonumber(min) * 60) + tonumber(sec)
    else
        -- Se o usuário digitar só um número (ex: 30), conta como segundos
        return tonumber(str) or 0
    end
end

-- Função auxiliar: Converte Segundos para Texto "MM:SS"
local function formatTime(seconds)
    if seconds < 0 then seconds = 0 end
    local min = math.floor(seconds / 60)
    local sec = seconds % 60
    return string.format("%02d:%02d", min, sec)
end

-- START
StartBtn.MouseButton1Click:Connect(function()
    if timerRunning then return end -- Já está rodando
    
    if not timerPaused then
        -- Se não estava pausado, lê o input novo
        totalSeconds = parseTime(TimeInput.Text)
        initialTime = totalSeconds
    end
    
    if totalSeconds <= 0 then return end
    
    timerRunning = true
    timerPaused = false
    TimeInput.TextEditable = false -- Bloqueia edição enquanto roda
    
    -- Loop do tempo
    task.spawn(function()
        while timerRunning and totalSeconds > 0 do
            task.wait(1)
            if not timerRunning then break end -- Segurança extra
            
            totalSeconds = totalSeconds - 1
            TimeInput.Text = formatTime(totalSeconds)
            
            if totalSeconds <= 0 then
                timerRunning = false
                TimeInput.TextEditable = true
                -- Toca um som ou muda cor pra avisar que acabou (opcional)
                TimeInput.TextColor3 = Color3.fromRGB(255, 50, 50)
                task.wait(1)
                TimeInput.TextColor3 = Color3.fromRGB(0, 255, 150)
            end
        end
    end)
end)

-- PAUSE
PauseBtn.MouseButton1Click:Connect(function()
    if timerRunning then
        timerRunning = false
        timerPaused = true -- Marca como pausado para não resetar o tempo
    end
end)

-- STOP
StopBtn.MouseButton1Click:Connect(function()
    timerRunning = false
    timerPaused = false
    totalSeconds = initialTime -- Volta para o tempo que o usuário configurou
    TimeInput.Text = formatTime(initialTime)
    TimeInput.TextEditable = true
end)

-- Formatação automática ao digitar
TimeInput.FocusLost:Connect(function()
    local val = parseTime(TimeInput.Text)
    TimeInput.Text = formatTime(val)
end)

Features & Information

Time/tempo bom pra ver os minutos passando.

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts