-- WalkSpeed Controller UI (Draggable + Presets + Boost)
-- LocalScript
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local humanoid
-- =====================
-- CONFIG
-- =====================
local CONFIG = {
MinSpeed = 8,
MaxSpeed = 120,
DefaultSpeed = 16,
Presets = {
Normal = 16,
Fast = 40,
Extreme = 80
},
BoostMultiplier = 2,
BoostDuration = 3,
SmoothTime = 0.15
}
-- =====================
-- STATE
-- =====================
local targetSpeed = CONFIG.DefaultSpeed
local currentSpeed = CONFIG.DefaultSpeed
local boosting = false
-- =====================
-- CHARACTER BIND
-- =====================
local function bindCharacter(char)
humanoid = char:WaitForChild("Humanoid")
humanoid.WalkSpeed = CONFIG.DefaultSpeed
end
player.CharacterAdded:Connect(bindCharacter)
if player.Character then
bindCharacter(player.Character)
end
-- =====================
-- UI
-- =====================
local gui = Instance.new("ScreenGui")
gui.Name = "WalkSpeedUI"
gui.ResetOnSpawn = false
gui.Parent = player:WaitForChild("PlayerGui")
local main = Instance.new("Frame")
main.Size = UDim2.fromOffset(360, 280)
main.Position = UDim2.fromScale(0.5, 0.5)
main.AnchorPoint = Vector2.new(0.5, 0.5)
main.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
main.BorderSizePixel = 0
main.Parent = gui
Instance.new("UICorner", main).CornerRadius = UDim.new(0, 10)
local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, 0, 0, 40)
title.BackgroundTransparency = 1
title.Text = "WalkSpeed Controller"
title.Font = Enum.Font.GothamMedium
title.TextSize = 18
title.TextColor3 = Color3.fromRGB(230, 230, 230)
title.Parent = main
-- =====================
-- DRAG SYSTEM
-- =====================
do
local dragging = false
local dragStart
local startPos
title.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1
or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = main.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
UIS.InputChanged:Connect(function(input)
if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement
or input.UserInputType == Enum.UserInputType.Touch) then
local delta = input.Position - dragStart
main.Position = UDim2.fromOffset(
startPos.X.Offset + delta.X,
startPos.Y.Offset + delta.Y
)
end
end)
end
-- =====================
-- SLIDER
-- =====================
local sliderBar = Instance.new("Frame", main)
sliderBar.Size = UDim2.fromOffset(300, 6)
sliderBar.Position = UDim2.fromOffset(30, 80)
sliderBar.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
sliderBar.BorderSizePixel = 0
local sliderFill = Instance.new("Frame", sliderBar)
sliderFill.Size = UDim2.fromScale(0, 1)
sliderFill.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
sliderFill.BorderSizePixel = 0
local knob = Instance.new("Frame", sliderBar)
knob.Size = UDim2.fromOffset(14, 14)
knob.Position = UDim2.new(0, -7, 0.5, -7)
knob.BackgroundColor3 = Color3.fromRGB(235, 235, 235)
knob.BorderSizePixel = 0
Instance.new("UICorner", knob).CornerRadius = UDim.new(1, 0)
-- =====================
-- PRESET BUTTONS
-- =====================
local function createButton(text, speed, x, y)
local b = Instance.new("TextButton")
b.Size = UDim2.fromOffset(90, 32)
b.Position = UDim2.fromOffset(x, y)
b.Text = text
b.Font = Enum.Font.Gotham
b.TextSize = 14
b.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
b.TextColor3 = Color3.fromRGB(200, 200, 200)
b.Parent = main
Instance.new("UICorner", b).CornerRadius = UDim.new(0, 6)
b.MouseButton1Click:Connect(function()
targetSpeed = speed
end)
end
createButton("Normal", CONFIG.Presets.Normal, 30, 110)
createButton("Fast", CONFIG.Presets.Fast, 135, 110)
createButton("Extreme", CONFIG.Presets.Extreme, 240, 110)
-- =====================
-- BOOST BUTTON
-- =====================
local boostButton = Instance.new("TextButton", main)
boostButton.Size = UDim2.fromOffset(300, 32)
boostButton.Position = UDim2.fromOffset(30, 160)
boostButton.Text = "Temporary Boost"
boostButton.Font = Enum.Font.GothamMedium
boostButton.TextSize = 14
boostButton.BackgroundColor3 = Color3.fromRGB(120, 60, 60)
boostButton.TextColor3 = Color3.fromRGB(255, 255, 255)
Instance.new("UICorner", boostButton).CornerRadius = UDim.new(0, 6)
boostButton.MouseButton1Click:Connect(function()
if boosting then return end
boosting = true
local original = targetSpeed
targetSpeed = math.clamp(
targetSpeed * CONFIG.BoostMultiplier,
CONFIG.MinSpeed,
CONFIG.MaxSpeed
)
task.delay(CONFIG.BoostDuration, function()
targetSpeed = original
boosting = false
end)
end)
-- =====================
-- SLIDER INPUT
-- =====================
local sliding = false
knob.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
sliding = true
end
end)
UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
sliding = false
end
end)
UIS.InputChanged:Connect(function(input)
if sliding and input.UserInputType == Enum.UserInputType.MouseMovement then
local alpha = math.clamp(
(input.Position.X - sliderBar.AbsolutePosition.X) / sliderBar.AbsoluteSize.X,
0, 1
)
targetSpeed = CONFIG.MinSpeed + (CONFIG.MaxSpeed - CONFIG.MinSpeed) * alpha
end
end)
-- =====================
-- UPDATE LOOP
-- =====================
RunService.RenderStepped:Connect(function(dt)
if not humanoid then return end
currentSpeed += (targetSpeed - currentSpeed) * math.clamp(dt / CONFIG.SmoothTime, 0, 1)
humanoid.WalkSpeed = currentSpeed
local alpha = (targetSpeed - CONFIG.MinSpeed) / (CONFIG.MaxSpeed - CONFIG.MinSpeed)
sliderFill.Size = UDim2.fromScale(alpha, 1)
knob.Position = UDim2.new(alpha, -7, 0.5, -7)
end)
Comments
No comments yet
Be the first to share your thoughts!