getcustomasset
Returns a content URL for a local file that can be used in the game.
Syntax
getcustomasset(path: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
path | string | The file path |
Returns
| Type | Description |
|---|---|
string | A content URL usable in the game |
Description
getcustomasset returns an rbxasset:// URL for a file in the workspace. It raises an error if the path is invalid or the file does not exist.
Example: Custom Image
-- The file must already exist in Volt's workspace
assert(isfile("myimage.png"), "Add myimage.png to the workspace first")
-- Get a usable URL
local imageUrl = getcustomasset("myimage.png")
-- Use it in a GUI
local imageLabel = Instance.new("ImageLabel")
imageLabel.Size = UDim2.fromOffset(256, 256)
imageLabel.Image = imageUrl
imageLabel.Parent = gethui()Notes
- The file must exist in the workspace folder
- The returned URL retains the source file's extension
- Whether the returned URL can be loaded depends on the API and file format used