Input

Fake keyboard and mouse input. Press, release, click, scroll and move the cursor without touching the real keyboard or mouse.

Overview

Fake input sent through Windows instead of Roblox's input system. That's the important part: it looks exactly like a real keyboard or mouse, but it goes to whatever window is focused.

Walking forward and clicking
-- Only send input when Roblox actually has focus.
if isrbxactive() then
    keypress(0x57)          -- W down
    task.wait(0.5)
    keyrelease(0x57)        -- W up

    mousemoverel(100, 0)    -- nudge the camera
    mouse1click()
end

Check focus first

Input goes to the focused window. Without an isrbxactive() check, a loop that presses W will type into whatever you alt-tabbed to.

Keyboard

Mouse buttons

Mouse motion & scroll

Focus

Three similar but different questions: is the window active, is it the Roblox window, and is the game actually taking input.