Ghi chú phát hành
Học
Lớp công cụ
AssetService
Không Thể Tạo
Dịch Vụ

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm Tắt
Phương Pháp
ComposeDecalAsync(decal: Decal,layers: {any}):()
CreateAssetAsync(object: Object,assetType: Enum.AssetType,requestParameters: Dictionary):Tuple
CreateAssetVersionAsync(object: Object,assetType: Enum.AssetType,assetId: number,requestParameters: Dictionary):Tuple
CreateEditableImageAsync(content: Content,editableImageOptions: Dictionary?):EditableImage
CreateEditableMeshAsync(content: Content,editableMeshOptions: Dictionary?):EditableMesh
CreatePlaceAsync(placeName: string,templatePlaceID: number,description: string):number
CreatePlaceInPlayerInventoryAsync(player: Instance,placeName: string,templatePlaceID: number,description: string):number
Đã Lỗi Thời
GetAssetIdsForPackage(packageAssetId: number):{any}
Đã Lỗi Thời
GetCreatorAssetID(creationID: number):number
Đã Lỗi Thời
SavePlaceAsync(requestParameters: Dictionary?):()
SearchAudio(searchParameters: AudioSearchParams):AudioPages
Đã Lỗi Thời
Thành viên kế thừa

Tài Liệu Tham Khảo API
Thuộc Tính
AllowInsertFreeAssets
Bảo Mật Kịch Bản Roblox
Đọc Song Song
AssetService.AllowInsertFreeAssets:boolean

Phương Pháp
ComposeDecalAsync
Sinh Lợi
AssetService:ComposeDecalAsync(
decal:Decal, layers:{any}
):()
Tham Số
decal:Decal
layers:{any}
Lợi Nhuận
()
Mẫu mã
local AssetService = game:GetService("AssetService")
-- Tạo hai thể hiện decal
local decalA = Instance.new("Decal")
local decalB = Instance.new("Decal")
-- Xây dựng bảng thông tin tổng hợp
local compositeInfo = {
{
ColorMap = decalA.ColorMapContent,
RoughnessMap = decalA.RoughnessMapContent,
MetalnessMap = decalA.MetalnessMapContent,
NormalMap = decalA.NormalMapContent,
},
{
ColorMap = Content.fromAssetId(123456),
RoughnessMap = decalB.RoughnessMapContent,
MetalnessMap = decalB.MetalnessMapContent,
NormalMap = decalB.NormalMapContent,
}
}
-- Tạo một decal để biên soạn lên
local compositeDecal = Instance.new("Decal")
-- Biên soạn một decal hiện có bằng AssetService
local success, errorMessage = pcall(function()
AssetService:ComposeDecalAsync(compositeDecal, compositeInfo)
end)
if success then
print("Decal đã biên soạn thành công!")
-- Logic để hiển thị/sử dụng decal ở đây
else
warn("Biên soạn decal thất bại:", errorMessage)
end

CreateAssetAsync
Sinh Lợi
Các khả năng: AssetCreateUpdate
AssetService:CreateAssetAsync(
object:Object, assetType:Enum.AssetType, requestParameters:Dictionary
Tham Số
object:Object
assetType:Enum.AssetType
requestParameters:Dictionary
Giá Trị Mặc Định: "nil"
Lợi Nhuận
Mẫu mã
AssetService:CreateAssetAsync
local AssetService = game:GetService("AssetService")
local editableMesh = AssetService:CreateEditableMesh()
-- thêm đỉnh, mặt, và uvs vào mesh
local requestParameters = {
CreatorId = 123,
CreatorType = Enum.AssetCreatorType.User,
Name = "Tài sản của tôi",
Description = "một tài sản tốt",
}
local ok, result, idOrUploadErr = pcall(function()
return AssetService:CreateAssetAsync(editableMesh, Enum.AssetType.Mesh, requestParameters)
end)
if not ok then
warn(`lỗi khi gọi CreateAssetAsync: {result}`)
elseif result == Enum.CreateAssetResult.Success then
print(`thành công, ID tài sản mới: {idOrUploadErr}`)
else
warn(`lỗi tải lên trong CreateAssetAsync: {result}, {idOrUploadErr}`)
end

CreateAssetVersionAsync
Sinh Lợi
Các khả năng: AssetCreateUpdate
AssetService:CreateAssetVersionAsync(
object:Object, assetType:Enum.AssetType, assetId:number, requestParameters:Dictionary
Tham Số
object:Object
assetType:Enum.AssetType
assetId:number
requestParameters:Dictionary
Giá Trị Mặc Định: "nil"
Lợi Nhuận
Mẫu mã
AssetService:CreateAssetVersionAsync
local AssetService = game:GetService("AssetService")
local assetIdToUpdate = 321
local model = Instance.new("Model")
local requestParameters = {
CreatorId = 123,
CreatorType = Enum.AssetCreatorType.User,
}
local ok, result, versionOrUploadErr = pcall(function()
return AssetService:CreateAssetVersionAsync(model, Enum.AssetType.Model, assetIdToUpdate, requestParameters)
end)
if not ok then
warn(`lỗi khi gọi CreateAssetVersionAsync: {result}`)
elseif result == Enum.CreateAssetResult.Success then
print(`thành công, phiên bản tài sản mới: {versionOrUploadErr}`)
else
warn(`lỗi tải lên trong CreateAssetVersionAsync: {result}, {versionOrUploadErr}`)
end

CreateDataModelContentAsync
Sinh Lợi
Các khả năng: DynamicGeneration
AssetService:CreateDataModelContentAsync(
content:Content, options:Dictionary?
Tham Số
content:Content
options:Dictionary?
Lợi Nhuận

CreateEditableImage
Các khả năng: DynamicGeneration
AssetService:CreateEditableImage(editableImageOptions:Dictionary?):EditableImage
Tham Số
editableImageOptions:Dictionary?
Lợi Nhuận

CreateEditableImageAsync
Sinh Lợi
Các khả năng: AssetRead
AssetService:CreateEditableImageAsync(
content:Content, editableImageOptions:Dictionary?
Tham Số
content:Content
editableImageOptions:Dictionary?
Lợi Nhuận

CreateEditableMesh
Các khả năng: DynamicGeneration
AssetService:CreateEditableMesh(editableMeshOptions:Dictionary?):EditableMesh
Tham Số
editableMeshOptions:Dictionary?
Lợi Nhuận

CreateEditableMeshAsync
Sinh Lợi
Các khả năng: AssetRead
AssetService:CreateEditableMeshAsync(
content:Content, editableMeshOptions:Dictionary?
Tham Số
content:Content
editableMeshOptions:Dictionary?
Lợi Nhuận

CreateMeshPartAsync
Sinh Lợi
Các khả năng: Basic
AssetService:CreateMeshPartAsync(
meshContent:Content, options:Dictionary
Tham Số
meshContent:Content
options:Dictionary
Giá Trị Mặc Định: "nil"
Lợi Nhuận

CreatePlaceAsync
Sinh Lợi
Các khả năng: AssetCreateUpdate
AssetService:CreatePlaceAsync(
placeName:string, templatePlaceID:number, description:string
Tham Số
placeName:string
templatePlaceID:number
description:string
Lợi Nhuận

CreatePlaceInPlayerInventoryAsync
Đã Lỗi Thời

CreateSurfaceAppearanceAsync
Sinh Lợi
Các khả năng: Basic
AssetService:CreateSurfaceAppearanceAsync(content:Dictionary):SurfaceAppearance
Tham Số
content:Dictionary
Lợi Nhuận
Mẫu mã
AssetService:CreateSurfaceAppearanceAsync
local AssetService = game:GetService("AssetService")
local Workspace = game:GetService("Workspace")
-- Màu đỏ
local colorEditableImage = AssetService:CreateEditableImage({ Size = Vector2.new(4, 4) })
colorEditableImage:DrawRectangle(Vector2.zero, colorEditableImage.Size, Color3.fromRGB(255, 0, 0), 0, Enum.ImageCombineType.Overwrite)
-- Độ kim loại (chỉ nhìn vào kênh màu đỏ)
local metalnessEditableImage = AssetService:CreateEditableImage({ Size = Vector2.new(1, 1) })
metalnessEditableImage:DrawRectangle(Vector2.zero, metalnessEditableImage.Size, Color3.new(1, 0, 0), 0, Enum.ImageCombineType.Overwrite)
-- Độ nhám (chỉ nhìn vào kênh màu đỏ)
local roughnessEditableImage = AssetService:CreateEditableImage({ Size = Vector2.new(1, 1) })
roughnessEditableImage:DrawRectangle(Vector2.zero, roughnessEditableImage.Size, Color3.new(0.2, 0, 0), 0, Enum.ImageCombineType.Overwrite)
local surfaceAppearance = AssetService:CreateSurfaceAppearanceAsync({
ColorMap = Content.fromObject(colorEditableImage),
MetalnessMap = Content.fromObject(metalnessEditableImage),
RoughnessMap = Content.fromObject(roughnessEditableImage)
})
local meshPart = Instance.new("MeshPart")
meshPart.Parent = Workspace
-- Áp dụng diện mạo bề mặt vào phần mesh
surfaceAppearance.Parent = meshPart

GetAssetIdsForPackage
Đã Lỗi Thời

GetAssetIdsForPackageAsync
Sinh Lợi
Các khả năng: AssetRead
AssetService:GetAssetIdsForPackageAsync(packageAssetId:number):{any}
Tham Số
packageAssetId:number
Lợi Nhuận

GetAudioMetadataAsync
Sinh Lợi
Các khả năng: AssetRead
AssetService:GetAudioMetadataAsync(idList:{any}):{any}
Tham Số
idList:{any}
Lợi Nhuận
Mẫu mã
local AssetService = game:GetService("AssetService")
local SoundService = game:GetService("SoundService")
local trackIDs = {
SoundService.Sound1.SoundId,
SoundService.Sound2.SoundId,
SoundService.Sound3.SoundId,
SoundService.Sound4.SoundId,
}
local success, result = pcall(function()
return AssetService:GetAudioMetadataAsync(trackIDs)
end)
if success then
for i = 1, #trackIDs do
local contentId = "rbxassetid://" .. result[i].AssetId
if trackIDs[i] == contentId then
print(result[i].Title, "bởi", result[i].Artist)
else
warn("Không có siêu dữ liệu nào được lấy cho tài sản yêu cầu #" .. tostring(i))
end
end
end

GetBundleDetailsAsync
Sinh Lợi
Các khả năng: AssetRead
AssetService:GetBundleDetailsAsync(bundleId:number):Dictionary
Tham Số
bundleId:number
Lợi Nhuận
Mẫu mã
Lấy Chi Tiết Gói
local AssetService = game:GetService("AssetService")
local BUNDLE_ID = 14
local success, result = pcall(function()
return AssetService:GetBundleDetailsAsync(BUNDLE_ID)
end)
if success then
print(result)
--[[
{
["BundleType"] = "BodyParts",
["Description"] = "Năm là 5003, Battlebot 5000 phải đối mặt với kẻ thù mạnh nhất của mình, hoặc phải đối mặt với việc trở nên lỗi thời.",
["Id"] = 14,
["Items"] = {
[1] = {...},
[2] = {
["Id"] = 1678225030,
["Name"] = "Cánh Tay Trái SinisterBot 5001",
["Type"] = "Tài sản"
},
[3] = {...},
[4] = {...},
[5] = {...},
[6] = {...},
[7] = {...}
},
["Name"] = "SinisterBot 5001"
}
--]]
end

GetCreatorAssetID
Đã Lỗi Thời

GetGamePlacesAsync
Sinh Lợi
Các khả năng: AssetRead
AssetService:GetGamePlacesAsync():Instance
Lợi Nhuận
Mẫu mã
AssetService:GetGamePlacesAsync
local AssetService = game:GetService("AssetService")
local placePages = AssetService:GetGamePlacesAsync()
while true do
for _, place in placePages:GetCurrentPage() do
print("Tên:", place.Name)
print("PlaceId:", place.PlaceId)
end
if placePages.IsFinished then
break
end
placePages:AdvanceToNextPageAsync()
end

LoadAssetAsync
Sinh Lợi
Các khả năng: LoadUnownedAsset
AssetService:LoadAssetAsync(assetId:number):Instance
Tham Số
assetId:number
Lợi Nhuận

PromptCreateAssetAsync
Sinh Lợi
Các khả năng: AssetCreateUpdate
AssetService:PromptCreateAssetAsync(
player:Player, instance:Instance, assetType:Enum.AssetType
Tham Số
player:Player
instance:Instance
assetType:Enum.AssetType
Lợi Nhuận

PromptImportAnimationClipFromVideoAsync
Sinh Lợi
Các khả năng: AssetManagement
AssetService:PromptImportAnimationClipFromVideoAsync(
player:Player, progressCallback:function
Tham Số
player:Player
progressCallback:function
Lợi Nhuận

SavePlaceAsync
Sinh Lợi
Các khả năng: AssetCreateUpdate
AssetService:SavePlaceAsync(requestParameters:Dictionary?):()
Tham Số
requestParameters:Dictionary?
Lợi Nhuận
()

SearchAudio
Đã Lỗi Thời

SearchAudioAsync
Sinh Lợi
Các khả năng: AssetRead
AssetService:SearchAudioAsync(searchParameters:AudioSearchParams):AudioPages
Tham Số
searchParameters:AudioSearchParams
Lợi Nhuận
Mẫu mã
Lấy Tiêu Đề Tìm Kiếm Nhạc
local AssetService = game:GetService("AssetService")
local audioSearchParams = Instance.new("AudioSearchParams")
audioSearchParams.SearchKeyword = "vui vẻ"
local success, result = pcall(function()
return AssetService:SearchAudioAsync(audioSearchParams)
end)
if success then
local currentPage = result:GetCurrentPage()
for _, audio in currentPage do
print(audio.Title)
end
else
warn("Lỗi AssetService: " .. result)
end
--[[ Định dạng dữ liệu trả về
{
"AudioType": string,
"Artist": string,
"Title": string,
"Tags": {
"string"
},
"Id": number,
"IsEndorsed": boolean,
"Description": string,
"Duration": number,
"CreateTime": string,
"UpdateTime": string,
"Creator": {
"Id": number,
"Name": string,
"Type": number,
"IsVerifiedCreator": boolean
}
}
--]]

©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.