getcustomasset Synchronous
getsynasset
Copy a workspace file, or a file the user picks with openfiledialog, into Kawaii's local asset store and get a Roblox content URI for it. Set that URI on a Roblox property that accepts image or other asset content.
getcustomasset(source: string | Document) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
source | string | Document | Workspace-relative path of an existing asset file, or a file Document returned by openfiledialog. |
Returns
stringAn rbxasset:// content URI.
Usage notes
A workspace path must name an existing file. A Document must be a file rather than a folder, and it does not need shared-storage access.
Identical bytes produce the same URI whether they come from a path or a Document. Blocked workspace file extensions are rejected for both sources. When a picked file's name has no extension, an image, audio, or video file type supplies one.
A Drawing Image uses its Data property with file bytes instead of this URI.
Differences from Volt
Volt documents access through explicitly created workspace symlinks. Kawaii rejects symlinks in workspace paths; all workspace operations remain subject to its path containment checks.
Example
local player = game:GetService("Players").LocalPlayer
local imagePath = "images/example.png" -- Or let the user pick a file below.
local source = isfile(imagePath) and imagePath or openfiledialog({ title = "Choose an image" })
if source and player then
local image = Instance.new("ImageLabel")
image.Image = getcustomasset(source)
image.Size = UDim2.fromOffset(120, 120)
image.Parent = player:WaitForChild("PlayerGui")
task.delay(5, function() image:Destroy() end)
end