Speed Acceleration
Key RequiredUniversal

Speed Acceleration

Universal ScriptYFMZombieYFMZombie 5.1K views 201 executesUpdated Feb 4, 2025
0.0/ 5(1 votes)
010% Positive
Lua Script•115 lines (3741 chars)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local runService = game:GetService("RunService")
local userInputService = game:GetService("UserInputService")

local screenGui = Instance.new("ScreenGui", player.PlayerGui)

local frame = Instance.new("Frame", screenGui)
frame.Size = UDim2.new(0, 200, 0, 140)
frame.Position = UDim2.new(0.5, -100, 0.1, 0)
frame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)

local dragBar = Instance.new("Frame", frame)
dragBar.Size = UDim2.new(1, 0, 0.2, 0)
dragBar.BackgroundColor3 = Color3.new(0.1, 0.1, 0.1)
dragBar.Active = true

local speedBox = Instance.new("TextBox", frame)
speedBox.Size = UDim2.new(1, 0, 0.3, 0)
speedBox.Position = UDim2.new(0, 0, 0.2, 0)
speedBox.PlaceholderText = "Max Speed"
speedBox.Text = ""

local accelBox = Instance.new("TextBox", frame)
accelBox.Size = UDim2.new(1, 0, 0.3, 0)
accelBox.Position = UDim2.new(0, 0, 0.5, 0)
accelBox.PlaceholderText = "Acceleration"
accelBox.Text = ""

local speedometer = Instance.new("TextLabel", frame)
speedometer.Size = UDim2.new(1, 0, 0.2, 0)
speedometer.Position = UDim2.new(0, 0, 0.8, 0)
speedometer.BackgroundColor3 = Color3.new(0.1, 0.1, 0.1)
speedometer.TextColor3 = Color3.new(1, 1, 1)
speedometer.Text = "Speed: 16"

local maxSpeed = 16
local acceleration = 0
local decelerationMultiplier = 2
local currentSpeed = 16
local boostAmount = 50
local boostCooldown = false

speedBox.FocusLost:Connect(function()
    local speed = tonumber(speedBox.Text)
    if speed then
        maxSpeed = speed
    end
end)

accelBox.FocusLost:Connect(function()
    local accel = tonumber(accelBox.Text)
    if accel then
        acceleration = accel
    end
end)

runService.RenderStepped:Connect(function(deltaTime)
    if humanoid.MoveDirection.Magnitude > 0 then
        if currentSpeed < maxSpeed then
            currentSpeed = math.min(currentSpeed + acceleration * deltaTime, maxSpeed)
        end
    else
        if currentSpeed > maxSpeed then
            currentSpeed = math.max(currentSpeed - (acceleration * decelerationMultiplier * deltaTime), maxSpeed)
        elseif currentSpeed > 16 then
            currentSpeed = math.max(currentSpeed - (acceleration * decelerationMultiplier * deltaTime), 16)
        end
    end
    humanoid.WalkSpeed = currentSpeed
    speedometer.Text = "Speed: " .. math.floor(currentSpeed)
end)

userInputService.InputBegan:Connect(function(input, gameProcessed)
    if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessed and not boostCooldown then
        boostCooldown = true
        currentSpeed = currentSpeed + boostAmount
        task.delay(2, function()
            boostCooldown = false
        end)
    end
end)

local dragging, dragInput, startPos

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

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

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

game:GetService("UserInputService").InputChanged:Connect(function(input)
    if input == dragInput and dragging then
        updateInput(input)
    end
end)

Features & Information

you can change your max speed and change the acceleration

Community Comments (2)

fakerthefakemanfakerthefakemanJul 23, 2025

can someone explain how acceleration works?

Replying to @fakerthefakeman
YFMZombieYFMZombieSep 19, 2025

@fakerthefakeman this might be a little late but basically you start off slow and slowly get faster and faster or you can make the acceleration fast and u can be like snap, its mostly for like avatars like if ur avatar is the flash or sonic u can use this script to reenact their speed

More Scripts for Universal Scripts