Auto-Run Toggle

@rebind / auto-run-togglev0.1.2Public

Tap one key to keep walking, with sprint if you want. Tap S to stop.

Files

main.luau938 B

-- Auto-Run Toggle: one key holds W (and sprint if you want) until you press
-- it again or press the stop key.

local cfg = UI.Schema({
  toggle = UI.Keybind("Grave", { label = "Auto-run on or off" }),
  stopKey = UI.Keybind("S", { label = "Also stops auto-run" }),
  sprint = UI.Toggle(false, { label = "Sprint too" }),
  sprintKey = UI.Keybind("LCtrl", { label = "Sprint key" }),
})

local running = false
local sprinting = nil

local function stop()
  if not running then
    return
  end
  HID.Up("W")
  if sprinting then
    HID.Up(sprinting)
  end
  running, sprinting = false, nil
end

Bind(cfg.toggle, function()
  if running then
    stop()
    return
  end
  running = true
  HID.Down("W")
  if cfg.sprint then
    sprinting = cfg.sprintKey
    HID.Down(sprinting)
  end
end)

-- the stop key still does its usual job, like stepping back
Bind(cfg.stopKey, function()
  stop()
  return true
end)

function OnStop()
  stop()
end

3 files, 2.4 KB.