writecustomasset Synchronous
Write bytes to a workspace file and get an asset URI for it in one step. Use it for an image or sound your script has just generated or downloaded.
Luau
writecustomasset(path: string, contents: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
path | string | Workspace-relative path to write, including the file extension. |
contents | string | File bytes, such as PNG or MP3 data. |
Returns
stringAn asset URI, the same as getcustomasset returns for that file.
Usage notes
Existing contents at the path are replaced. The file stays in the workspace afterwards, as if you had called writefile and then getcustomasset.
Example
Luau
local image = game:HttpGet("https://example.com/icon.png")
local decal = Instance.new("Decal")
decal.Texture = writecustomasset("assets/icon.png", image)