เรียนรู้
Engine Class
AssetService
ไม่สามารถสร้าง
บริการ

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
คุณสมบัติ
วิธีการ
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
เลิกใช้แล้ว
GetAssetIdsForPackage(packageAssetId: number):{any}
เลิกใช้แล้ว
GetCreatorAssetID(creationID: number):number
เลิกใช้แล้ว
SavePlaceAsync(requestParameters: Dictionary?):()
SearchAudio(searchParameters: AudioSearchParams):AudioPages
เลิกใช้แล้ว
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
AllowInsertFreeAssets
การรักษาความปลอดภัยของสคริปต์ Roblox
อ่านพร้อมๆ กัน
AssetService.AllowInsertFreeAssets:boolean

วิธีการ
ComposeDecalAsync
ผลตอบแทน
AssetService:ComposeDecalAsync(
decal:Decal, layers:{any}
):()
พารามิเตอร์
decal:Decal
layers:{any}
ส่งค่ากลับ
()
ตัวอย่างโค้ด
local AssetService = game:GetService("AssetService")
-- สร้างอินสแตนซ์ของ decal สองตัว
local decalA = Instance.new("Decal")
local decalB = Instance.new("Decal")
-- สร้างตารางข้อมูล composite
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,
}
}
-- สร้าง decal เพื่อรวม
local compositeDecal = Instance.new("Decal")
-- รวม decal ที่มีอยู่โดยใช้ AssetService
local success, errorMessage = pcall(function()
AssetService:ComposeDecalAsync(compositeDecal, compositeInfo)
end)
if success then
print("รวม decal สำเร็จ!")
-- Logic เพื่อแสดง/ใช้ decal ที่นี่
else
warn("ล้มเหลวในการรวม decal:", errorMessage)
end

CreateAssetAsync
ผลตอบแทน
ความสามารถ: AssetCreateUpdate
AssetService:CreateAssetAsync(
object:Object, assetType:Enum.AssetType, requestParameters:Dictionary
พารามิเตอร์
object:Object
assetType:Enum.AssetType
requestParameters:Dictionary
ค่าเริ่มต้น: "nil"
ส่งค่ากลับ
ตัวอย่างโค้ด
AssetService:CreateAssetAsync
local AssetService = game:GetService("AssetService")
local editableMesh = AssetService:CreateEditableMesh()
-- เพิ่มจุดยอด, หน้าต่าง, และ uvs ไปยังเมช
local requestParameters = {
CreatorId = 123,
CreatorType = Enum.AssetCreatorType.User,
Name = "ทรัพย์สินของฉัน",
Description = "ทรัพย์สินที่ดี",
}
local ok, result, idOrUploadErr = pcall(function()
return AssetService:CreateAssetAsync(editableMesh, Enum.AssetType.Mesh, requestParameters)
end)
if not ok then
warn(`เกิดข้อผิดพลาดเมื่อเรียก CreateAssetAsync: {result}`)
elseif result == Enum.CreateAssetResult.Success then
print(`สำเร็จ, ID ทรัพย์สินใหม่: {idOrUploadErr}`)
else
warn(`ข้อผิดพลาดในการอัปโหลดใน CreateAssetAsync: {result}, {idOrUploadErr}`)
end

CreateAssetVersionAsync
ผลตอบแทน
ความสามารถ: AssetCreateUpdate
AssetService:CreateAssetVersionAsync(
object:Object, assetType:Enum.AssetType, assetId:number, requestParameters:Dictionary
พารามิเตอร์
object:Object
assetType:Enum.AssetType
assetId:number
requestParameters:Dictionary
ค่าเริ่มต้น: "nil"
ส่งค่ากลับ
ตัวอย่างโค้ด
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(`เกิดข้อผิดพลาดในการเรียก CreateAssetVersionAsync: {result}`)
elseif result == Enum.CreateAssetResult.Success then
print(`สำเร็จ, เวอร์ชันสินทรัพย์ใหม่: {versionOrUploadErr}`)
else
warn(`เกิดข้อผิดพลาดในการอัปโหลดใน CreateAssetVersionAsync: {result}, {versionOrUploadErr}`)
end

CreateDataModelContentAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
AssetService:CreateDataModelContentAsync(
content:Content, options:Dictionary?
พารามิเตอร์
content:Content
options:Dictionary?
ส่งค่ากลับ

CreateEditableImage
ความสามารถ: DynamicGeneration
AssetService:CreateEditableImage(editableImageOptions:Dictionary?):EditableImage
พารามิเตอร์
editableImageOptions:Dictionary?
ส่งค่ากลับ

CreateEditableImageAsync
ผลตอบแทน
ความสามารถ: AssetRead
AssetService:CreateEditableImageAsync(
content:Content, editableImageOptions:Dictionary?
พารามิเตอร์
content:Content
editableImageOptions:Dictionary?
ส่งค่ากลับ

CreateEditableMesh
ความสามารถ: DynamicGeneration
AssetService:CreateEditableMesh(editableMeshOptions:Dictionary?):EditableMesh
พารามิเตอร์
editableMeshOptions:Dictionary?
ส่งค่ากลับ

CreateEditableMeshAsync
ผลตอบแทน
ความสามารถ: AssetRead
AssetService:CreateEditableMeshAsync(
content:Content, editableMeshOptions:Dictionary?
พารามิเตอร์
content:Content
editableMeshOptions:Dictionary?
ส่งค่ากลับ

CreateMeshPartAsync
ผลตอบแทน
ความสามารถ: Basic
AssetService:CreateMeshPartAsync(
meshContent:Content, options:Dictionary
พารามิเตอร์
meshContent:Content
options:Dictionary
ค่าเริ่มต้น: "nil"
ส่งค่ากลับ

CreatePlaceAsync
ผลตอบแทน
ความสามารถ: AssetCreateUpdate
AssetService:CreatePlaceAsync(
placeName:string, templatePlaceID:number, description:string
พารามิเตอร์
placeName:string
templatePlaceID:number
description:string
ส่งค่ากลับ

CreatePlaceInPlayerInventoryAsync
เลิกใช้แล้ว

CreateSurfaceAppearanceAsync
ผลตอบแทน
ความสามารถ: Basic
AssetService:CreateSurfaceAppearanceAsync(content:Dictionary):SurfaceAppearance
พารามิเตอร์
content:Dictionary
ส่งค่ากลับ
ตัวอย่างโค้ด
AssetService:CreateSurfaceAppearanceAsync
local AssetService = game:GetService("AssetService")
local Workspace = game:GetService("Workspace")
-- สีแดง
local colorEditableImage = AssetService:CreateEditableImage({ Size = Vector2.new(4, 4) })
colorEditableImage:DrawRectangle(Vector2.zero, colorEditableImage.Size, Color3.fromRGB(255, 0, 0), 0, Enum.ImageCombineType.Overwrite)
-- Metalness (ดูเฉพาะช่องสีแดง)
local metalnessEditableImage = AssetService:CreateEditableImage({ Size = Vector2.new(1, 1) })
metalnessEditableImage:DrawRectangle(Vector2.zero, metalnessEditableImage.Size, Color3.new(1, 0, 0), 0, Enum.ImageCombineType.Overwrite)
-- Roughness (ดูเฉพาะช่องสีแดง)
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
-- ประยุกต์ใช้การปรากฏพื้นผิวกับส่วนของเมช
surfaceAppearance.Parent = meshPart

GetAssetIdsForPackage
เลิกใช้แล้ว

GetAssetIdsForPackageAsync
ผลตอบแทน
ความสามารถ: AssetRead
AssetService:GetAssetIdsForPackageAsync(packageAssetId:number):{any}
พารามิเตอร์
packageAssetId:number
ส่งค่ากลับ

GetAudioMetadataAsync
ผลตอบแทน
ความสามารถ: AssetRead
AssetService:GetAudioMetadataAsync(idList:{any}):{any}
พารามิเตอร์
idList:{any}
ส่งค่ากลับ
ตัวอย่างโค้ด
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, "โดย", result[i].Artist)
else
warn("ไม่มีข้อมูลเมตาสำหรับสินทรัพย์ที่ร้องขอ #" .. tostring(i))
end
end
end

GetBundleDetailsAsync
ผลตอบแทน
ความสามารถ: AssetRead
AssetService:GetBundleDetailsAsync(bundleId:number):Dictionary
พารามิเตอร์
bundleId:number
ส่งค่ากลับ
ตัวอย่างโค้ด
ข้อมูลแพ็คเกจ
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"] = "ปีคือ 5003, Battlebot 5000 จะต้องเผชิญหน้ากับศัตรูที่เก่งกาจที่สุดของเขา, หรือจะต้องกลายเป็นของล้าสมัย.",
["Id"] = 14,
["Items"] = {
[1] = {...},
[2] = {
["Id"] = 1678225030,
["Name"] = "SinisterBot 5001 แขนซ้าย",
["Type"] = "Asset"
},
[3] = {...},
[4] = {...},
[5] = {...},
[6] = {...},
[7] = {...}
},
["Name"] = "SinisterBot 5001"
}
--]]
end

GetCreatorAssetID
เลิกใช้แล้ว

GetGamePlacesAsync
ผลตอบแทน
ความสามารถ: AssetRead
AssetService:GetGamePlacesAsync():Instance
ส่งค่ากลับ
ตัวอย่างโค้ด
AssetService:GetGamePlacesAsync
local AssetService = game:GetService("AssetService")
local placePages = AssetService:GetGamePlacesAsync()
while true do
for _, place in placePages:GetCurrentPage() do
print("ชื่อ:", place.Name)
print("PlaceId:", place.PlaceId)
end
if placePages.IsFinished then
break
end
placePages:AdvanceToNextPageAsync()
end

LoadAssetAsync
ผลตอบแทน
ความสามารถ: LoadUnownedAsset
AssetService:LoadAssetAsync(assetId:number):Instance
พารามิเตอร์
assetId:number
ส่งค่ากลับ

PromptCreateAssetAsync
ผลตอบแทน
ความสามารถ: AssetCreateUpdate
AssetService:PromptCreateAssetAsync(
player:Player, instance:Instance, assetType:Enum.AssetType
พารามิเตอร์
player:Player
instance:Instance
assetType:Enum.AssetType
ส่งค่ากลับ

PromptImportAnimationClipFromVideoAsync
ผลตอบแทน
ความสามารถ: AssetManagement
AssetService:PromptImportAnimationClipFromVideoAsync(
player:Player, progressCallback:function
พารามิเตอร์
player:Player
progressCallback:function
ส่งค่ากลับ

SavePlaceAsync
ผลตอบแทน
ความสามารถ: AssetCreateUpdate
AssetService:SavePlaceAsync(requestParameters:Dictionary?):()
พารามิเตอร์
requestParameters:Dictionary?
ส่งค่ากลับ
()

SearchAudio
เลิกใช้แล้ว

SearchAudioAsync
ผลตอบแทน
ความสามารถ: AssetRead
AssetService:SearchAudioAsync(searchParameters:AudioSearchParams):AudioPages
พารามิเตอร์
searchParameters:AudioSearchParams
ส่งค่ากลับ
ตัวอย่างโค้ด
การค้นหาชื่อเพลง
local AssetService = game:GetService("AssetService")
local audioSearchParams = Instance.new("AudioSearchParams")
audioSearchParams.SearchKeyword = "มีความสุข"
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("ข้อผิดพลาดของ AssetService: " .. result)
end
--[[ รูปแบบข้อมูลที่ส่งกลับ
{
"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, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ