local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local toggleKey = Enum.KeyCode.F
local resetKey = Enum.KeyCode.R
local isRunning = false
local elapsedTime = 0
local waitingForBind = nil
local BASE_WIDTH = 260
local BASE_HEIGHT = 75
local currentScale = 1
local COLOR_RUNNING = Color3.fromRGB(76, 217, 100)
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "SpeedrunTimerGui"
screenGui.ResetOnSpawn = false
screenGui.DisplayOrder = 999999
screenGui.IgnoreGuiInset = true
screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
screenGui.Parent = playerGui
local timerFrame = Instance.new("Frame")
timerFrame.Name = "TimerFrame"
timerFrame.Size = UDim2.new(0, BASE_WIDTH, 0, BASE_HEIGHT)
timerFrame.Position = UDim2.new(0.5, -BASE_WIDTH/2, 0, 40)
timerFrame.BackgroundColor3 = Color3.fromRGB(12, 12, 12)
timerFrame.BorderSizePixel = 0
timerFrame.Active = true
timerFrame.Parent = screenGui
local timerScale = Instance.new("UIScale")
timerScale.Scale = 1
timerScale.Parent = timerFrame
local timerCorner = Instance.new("UICorner")
timerCorner.CornerRadius = UDim.new(0, 6)
timerCorner.Parent = timerFrame
local timerLabel = Instance.new("TextLabel")
timerLabel.Name = "TimerLabel"
timerLabel.Size = UDim2.new(1, -20, 1, 0)
timerLabel.Position = UDim2.new(0, 10, 0, 0)
timerLabel.BackgroundTransparency = 1
timerLabel.RichText = true
timerLabel.Text = '00:00.00'
timerLabel.Font = Enum.Font.GothamBold
timerLabel.TextColor3 = COLOR_RUNNING
timerLabel.TextSize = 56
timerLabel.TextXAlignment = Enum.TextXAlignment.Right
timerLabel.TextYAlignment = Enum.TextYAlignment.Bottom
timerLabel.Parent = timerFrame
local openSettingsBtn = Instance.new("TextButton")
openSettingsBtn.Size = UDim2.new(0, 22, 0, 22)
openSettingsBtn.Position = UDim2.new(0, 4, 0, 4)
openSettingsBtn.BackgroundTransparency = 1
openSettingsBtn.Text = "⚙"
openSettingsBtn.TextColor3 = Color3.fromRGB(100, 100, 100)
openSettingsBtn.TextSize = 16
openSettingsBtn.Font = Enum.Font.GothamBold
openSettingsBtn.Parent = timerFrame
local resizeHandle = Instance.new("TextButton")
resizeHandle.Name = "ResizeHandle"
resizeHandle.Size = UDim2.new(0, 18, 0, 18)
resizeHandle.Position = UDim2.new(1, -18, 1, -18)
resizeHandle.BackgroundTransparency = 1
resizeHandle.Text = "◢"
resizeHandle.TextColor3 = Color3.fromRGB(80, 80, 80)
resizeHandle.TextSize = 12
resizeHandle.Font = Enum.Font.GothamBold
resizeHandle.Parent = timerFrame
local settingsFrame = Instance.new("Frame")
settingsFrame.Name = "SettingsFrame"
settingsFrame.Size = UDim2.new(0, 280, 0, 210)
settingsFrame.Position = UDim2.new(0.5, -140, 0.5, -105)
settingsFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
settingsFrame.BorderSizePixel = 0
settingsFrame.Active = true
settingsFrame.ZIndex = 10
settingsFrame.Parent = screenGui
Instance.new("UICorner", settingsFrame).CornerRadius = UDim.new(0, 8)
local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, -40, 0, 35)
titleLabel.Position = UDim2.new(0, 15, 0, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = "Timer Settings"
titleLabel.Font = Enum.Font.GothamBold
titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
titleLabel.TextSize = 16
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.Parent = settingsFrame
local closeBtn = Instance.new("TextButton")
closeBtn.Size = UDim2.new(0, 30, 0, 30)
closeBtn.Position = UDim2.new(1, -35, 0, 3)
closeBtn.BackgroundTransparency = 1
closeBtn.Text = ""
closeBtn.Parent = settingsFrame
local closeLine1 = Instance.new("Frame")
closeLine1.Size = UDim2.new(0, 16, 0, 3)
closeLine1.Position = UDim2.new(0.5, 0, 0.5, 0)
closeLine1.AnchorPoint = Vector2.new(0.5, 0.5)
closeLine1.Rotation = 45
closeLine1.BackgroundColor3 = COLOR_RUNNING
closeLine1.BorderSizePixel = 0
closeLine1.Parent = closeBtn
Instance.new("UICorner", closeLine1).CornerRadius = UDim.new(1, 0)
local closeLine2 = Instance.new("Frame")
closeLine2.Size = UDim2.new(0, 16, 0, 3)
closeLine2.Position = UDim2.new(0.5, 0, 0.5, 0)
closeLine2.AnchorPoint = Vector2.new(0.5, 0.5)
closeLine2.Rotation = -45
closeLine2.BackgroundColor3 = COLOR_RUNNING
closeLine2.BorderSizePixel = 0
closeLine2.Parent = closeBtn
Instance.new("UICorner", closeLine2).CornerRadius = UDim.new(1, 0)
local toggleBindText = Instance.new("TextLabel")
toggleBindText.Size = UDim2.new(0.5, 0, 0, 35)
toggleBindText.Position = UDim2.new(0, 15, 0, 45)
toggleBindText.BackgroundTransparency = 1
toggleBindText.Text = "Start / Pause:"
toggleBindText.Font = Enum.Font.Gotham
toggleBindText.TextColor3 = Color3.fromRGB(200, 200, 200)
toggleBindText.TextSize = 15
toggleBindText.TextXAlignment = Enum.TextXAlignment.Left
toggleBindText.Parent = settingsFrame
local toggleBindBtn = Instance.new("TextButton")
toggleBindBtn.Size = UDim2.new(0, 100, 0, 32)
toggleBindBtn.Position = UDim2.new(1, -115, 0, 46)
toggleBindBtn.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
toggleBindBtn.Text = toggleKey.Name
toggleBindBtn.Font = Enum.Font.GothamBold
toggleBindBtn.TextColor3 = COLOR_RUNNING
toggleBindBtn.TextSize = 15
toggleBindBtn.Parent = settingsFrame
Instance.new("UICorner", toggleBindBtn).CornerRadius = UDim.new(0, 6)
local resetBindText = Instance.new("TextLabel")
resetBindText.Size = UDim2.new(0.5, 0, 0, 35)
resetBindText.Position = UDim2.new(0, 15, 0, 95)
resetBindText.BackgroundTransparency = 1
resetBindText.Text = "Reset Timer:"
resetBindText.Font = Enum.Font.Gotham
resetBindText.TextColor3 = Color3.fromRGB(200, 200, 200)
resetBindText.TextSize = 15
resetBindText.TextXAlignment = Enum.TextXAlignment.Left
resetBindText.Parent = settingsFrame
local resetBindBtn = Instance.new("TextButton")
resetBindBtn.Size = UDim2.new(0, 100, 0, 32)
resetBindBtn.Position = UDim2.new(1, -115, 0, 96)
resetBindBtn.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
resetBindBtn.Text = resetKey.Name
resetBindBtn.Font = Enum.Font.GothamBold
resetBindBtn.TextColor3 = COLOR_RUNNING
resetBindBtn.TextSize = 15
resetBindBtn.Parent = settingsFrame
Instance.new("UICorner", resetBindBtn).CornerRadius = UDim.new(0, 6)
local sizeText = Instance.new("TextLabel")
sizeText.Size = UDim2.new(0.5, 0, 0, 35)
sizeText.Position = UDim2.new(0, 15, 0, 145)
sizeText.BackgroundTransparency = 1
sizeText.Text = "GUI Size:"
sizeText.Font = Enum.Font.Gotham
sizeText.TextColor3 = Color3.fromRGB(200, 200, 200)
sizeText.TextSize = 15
sizeText.TextXAlignment = Enum.TextXAlignment.Left
sizeText.Parent = settingsFrame
local minusBtn = Instance.new("TextButton")
minusBtn.Size = UDim2.new(0, 28, 0, 32)
minusBtn.Position = UDim2.new(1, -115, 0, 146)
minusBtn.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
minusBtn.Text = "-"
minusBtn.Font = Enum.Font.GothamBold
minusBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
minusBtn.TextSize = 18
minusBtn.Parent = settingsFrame
Instance.new("UICorner", minusBtn).CornerRadius = UDim.new(0, 6)
local scaleValueBtn = Instance.new("TextButton")
scaleValueBtn.Size = UDim2.new(0, 38, 0, 32)
scaleValueBtn.Position = UDim2.new(1, -84, 0, 146)
scaleValueBtn.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
scaleValueBtn.Text = "100%"
scaleValueBtn.Font = Enum.Font.GothamBold
scaleValueBtn.TextColor3 = COLOR_RUNNING
scaleValueBtn.TextSize = 12
scaleValueBtn.Parent = settingsFrame
Instance.new("UICorner", scaleValueBtn).CornerRadius = UDim.new(0, 6)
local plusBtn = Instance.new("TextButton")
plusBtn.Size = UDim2.new(0, 28, 0, 32)
plusBtn.Position = UDim2.new(1, -43, 0, 146)
plusBtn.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
plusBtn.Text = "+"
plusBtn.Font = Enum.Font.GothamBold
plusBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
plusBtn.TextSize = 18
plusBtn.Parent = settingsFrame
Instance.new("UICorner", plusBtn).CornerRadius = UDim.new(0, 6)
local function setScale(newScale)
currentScale = math.clamp(newScale, 0.4, 3.0)
timerScale.Scale = currentScale
scaleValueBtn.Text = math.round(currentScale * 100) .. "%"
end
minusBtn.MouseButton1Click:Connect(function() setScale(currentScale - 0.1) end)
plusBtn.MouseButton1Click:Connect(function() setScale(currentScale + 0.1) end)
scaleValueBtn.MouseButton1Click:Connect(function() setScale(1.0) end)
local isResizing = false
local resizeStartPos = nil
local startScale = 1
resizeHandle.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
isResizing = true
resizeStartPos = input.Position
startScale = currentScale
end
end)
local function makeDraggable(frame)
local dragging = false
local dragStart = nil
local startPos = nil
frame.InputBegan:Connect(function(input)
if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) and not isResizing then
dragging = true
dragStart = input.Position
startPos = frame.Position
end
end)
UserInputService.InputChanged:Connect(function(input)
if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
if isResizing then
dragging = false
return
end
local delta = input.Position - dragStart
frame.Position = UDim2.new(
startPos.X.Scale, startPos.X.Offset + delta.X,
startPos.Y.Scale, startPos.Y.Offset + delta.Y
)
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = false
end
end)
end
makeDraggable(timerFrame)
makeDraggable(settingsFrame)
UserInputService.InputChanged:Connect(function(input)
if isResizing and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
local delta = input.Position - resizeStartPos
local scaleChange = delta.X / BASE_WIDTH
setScale(startScale + scaleChange)
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
isResizing = false
end
end)
local function formatTime(seconds)
local mins = math.floor(seconds / 60)
local secs = math.floor(seconds % 60)
local ms = math.floor((seconds * 100) % 100)
return string.format('%02d:%02d.%02d', mins, secs, ms)
end
RunService.RenderStepped:Connect(function(deltaTime)
if isRunning then
elapsedTime += deltaTime
timerLabel.Text = formatTime(elapsedTime)
end
end)
closeBtn.MouseButton1Click:Connect(function()
settingsFrame.Visible = false
waitingForBind = nil
end)
openSettingsBtn.MouseButton1Click:Connect(function()
settingsFrame.Visible = not settingsFrame.Visible
waitingForBind = nil
end)
toggleBindBtn.MouseButton1Click:Connect(function()
waitingForBind = "Toggle"
toggleBindBtn.Text = "..."
resetBindBtn.Text = resetKey.Name
end)
resetBindBtn.MouseButton1Click:Connect(function()
waitingForBind = "Reset"
resetBindBtn.Text = "..."
toggleBindBtn.Text = toggleKey.Name
end)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
if waitingForBind == "Toggle" then
toggleKey = input.KeyCode
toggleBindBtn.Text = toggleKey.Name
waitingForBind = nil
return
elseif waitingForBind == "Reset" then
resetKey = input.KeyCode
resetBindBtn.Text = resetKey.Name
waitingForBind = nil
return
end
if input.KeyCode == toggleKey then
isRunning = not isRunning
elseif input.KeyCode == resetKey then
isRunning = false
elapsedTime = 0
timerLabel.Text = formatTime(0)
end
end
end)