ReferenceFilesystem

readfileasync

Reads the complete contents of a workspace file. It has the same result as readfile.

Syntax

readfileasync(path: string): string

Parameters

ParameterTypeDescription
pathstringWorkspace-relative file.

Returns

TypeDescription
stringFile contents.

Description

Use readfile for the full path, error and return contract. The Async spelling does not grant access outside the workspace and does not mean that a callback argument is required. It suspends the calling thread once before running, so a thread started with task.spawn is still alive when task.spawn returns.

Example

local result = readfileasync("example.luau")
print(result)

These are Game executor contracts. Check build requirements and session lifetimes before using them.