rconsoleinput
Gets input from the user via the console.
Syntax
rconsoleinput() -> stringAliases
consoleinput
Returns
| Type | Description |
|---|---|
string | The user's input |
Description
rconsoleinput waits for the user to type something in the console and press Enter, then returns the input as a string. This is a yielding function.
Example
rconsoleshow()
rconsoleprint("What is your name? ")
local name = rconsoleinput()
rconsoleprint("Hello, " .. name .. "!\n")Interactive Menu Example
rconsoleshow()
rconsolename("Script Menu")
rconsoleprint("Select an option:\n")
rconsoleprint("1. Option A\n")
rconsoleprint("2. Option B\n")
rconsoleprint("3. Exit\n\n")
rconsoleprint("Enter choice: ")
local choice = rconsoleinput()
if choice == "1" then
rconsoleprint("You selected Option A\n")
elseif choice == "2" then
rconsoleprint("You selected Option B\n")
else
rconsoleprint("Goodbye!\n")
task.wait(1)
rconsolehide()
endNotes
- This function yields until the user presses Enter
- Returns an empty string if the console is closed
Related Functions
rconsoleprint- Print to console