iswindowactive
Checks if the game window is currently focused.
Syntax
iswindowactive() -> booleanAliases
isrbxactiveisgameactive
Returns
| Type | Description |
|---|---|
boolean | True if game window is focused |
Description
iswindowactive returns whether the Roblox game window is currently the active/focused window. This is useful for input simulation to ensure inputs only occur when the game is focused.
Example
-- Only simulate input when game is focused
if iswindowactive() then
keypress(0x20) -- Press space
task.wait(0.1)
keyrelease(0x20)
endWait for Focus
-- Wait until game is focused before executing
repeat task.wait() until iswindowactive()
print("Game is now focused!")Related Functions
keypress- Simulate key pressmouse1click- Simulate mouse click