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

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


สรุป
วิธีการ
CaptureScreenshot(onCaptureReady: function):()
PromptSaveCapturesToGallery(captures: {any},resultCallback: function):()
PromptShareCapture(captureContent: Content,launchData: string,onAcceptedCallback: function,onDeniedCallback: function):()
ReadCapturesFromGalleryAsync(captureTypeFilters: {any},readFromAllEligibleExperiences: boolean):Tuple
TakeScreenshotCaptureAsync(onCaptureReady: function,captureParams: Dictionary):()
เหตุการณ์
CaptureSaved(captureInfo: Dictionary):RBXScriptSignal
เลิกใช้แล้ว
UserCaptureSaved(captureContentId: ContentId):RBXScriptSignal
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
CaptureScreenshot
ความสามารถ: Capture
CaptureService:CaptureScreenshot(onCaptureReady:function):()
พารามิเตอร์
onCaptureReady:function
ส่งค่ากลับ
()

CheckUploadCaptureStatusAsync
ผลตอบแทน
ความสามารถ: Capture
CaptureService:CheckUploadCaptureStatusAsync(token:string):Tuple
พารามิเตอร์
token:string
ส่งค่ากลับ

PromptCaptureGalleryPermissionAsync
ผลตอบแทน
ความสามารถ: Capture
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
พารามิเตอร์
captureGalleryPermission:Enum.CaptureGalleryPermission
ส่งค่ากลับ
ตัวอย่างโค้ด
ขออนุญาตเข้าถึงแกลลอรีการจับภาพ
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
end

PromptSaveCapturesToGallery
ความสามารถ: Capture
CaptureService:PromptSaveCapturesToGallery(
captures:{any}, resultCallback:function
):()
พารามิเตอร์
captures:{any}
resultCallback:function
ส่งค่ากลับ
()

PromptShareCapture
ความสามารถ: Capture
CaptureService:PromptShareCapture(
captureContent:Content, launchData:string, onAcceptedCallback:function, onDeniedCallback:function
):()
พารามิเตอร์
captureContent:Content
launchData:string
onAcceptedCallback:function
onDeniedCallback:function
ส่งค่ากลับ
()

ReadCapturesFromGalleryAsync
ผลตอบแทน
ความสามารถ: Capture
CaptureService:ReadCapturesFromGalleryAsync(
captureTypeFilters:{any}, readFromAllEligibleExperiences:boolean
พารามิเตอร์
captureTypeFilters:{any}
ค่าเริ่มต้น: "{}"
readFromAllEligibleExperiences:boolean
ค่าเริ่มต้น: false
ส่งค่ากลับ
ตัวอย่างโค้ด
อ่านการบันทึกจากแกลเลอรีและวนซ้ำผ่านหน้า
local CaptureService = game:GetService("CaptureService")
local function readCapturesFromGallery()
local allCaptures = {}
local capturesPages
local success, result = pcall(function()
local readResult, pages = CaptureService:ReadCapturesFromGalleryAsync({}, false)
if readResult == Enum.ReadCapturesFromGalleryResult.Success then
capturesPages = pages
end
return readResult
end)
if not success or result ~= Enum.ReadCapturesFromGalleryResult.Success then
-- เป็นไปได้ว่าเกิดข้อผิดพลาดด้านสิทธิ์, ดูที่ CaptureService:PromptCaptureGalleryPermissionAsync()
warn("ไม่สามารถดึงข้อมูลการจับภาพเริ่มต้นได้: " .. result.Name)
return
end
-- ทำซ้ำผ่านหน้าปัจจุบัน
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- ขยับไปยังหน้าถัดไปจนเสร็จสิ้น
while not capturesPages.IsFinished do
local advanceToNextPageSuccess, _ = pcall(function()
capturesPages:AdvanceToNextPageAsync()
end)
if not advanceToNextPageSuccess then
return
end
currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
end
return allCaptures
end

StartUploadCaptureAsync
ผลตอบแทน
ความสามารถ: Capture
CaptureService:StartUploadCaptureAsync(capture:Capture):Tuple
พารามิเตอร์
capture:Capture
ส่งค่ากลับ

StartVideoCaptureAsync
ผลตอบแทน
ความสามารถ: Capture
CaptureService:StartVideoCaptureAsync(
onCaptureReady:function, captureParams:Dictionary
พารามิเตอร์
onCaptureReady:function
captureParams:Dictionary
ค่าเริ่มต้น: "nil"
ส่งค่ากลับ

StopVideoCapture
ความสามารถ: Capture
CaptureService:StopVideoCapture():()
ส่งค่ากลับ
()

TakeScreenshotCaptureAsync
ความสามารถ: Capture
CaptureService:TakeScreenshotCaptureAsync(
onCaptureReady:function, captureParams:Dictionary
):()
พารามิเตอร์
onCaptureReady:function
captureParams:Dictionary
ค่าเริ่มต้น: "nil"
ส่งค่ากลับ
()

UploadCaptureAsync
ผลตอบแทน
ความสามารถ: Capture
CaptureService:UploadCaptureAsync(capture:Capture):Tuple
พารามิเตอร์
capture:Capture
ส่งค่ากลับ
ตัวอย่างโค้ด
อัปโหลดการจับภาพไปยังระบบสินทรัพย์
local CaptureService = game:GetService("CaptureService")
local function uploadCapture(capture: Capture)
local success, result = pcall(function()
local uploadCaptureResult, assetId = CaptureService:UploadCaptureAsync(capture)
if uploadCaptureResult ~= Enum.UploadCaptureResult.Success then
-- จัดการความล้มเหลว
return nil
end
return assetId
end)
if not success then
-- จัดการข้อผิดพลาด
return nil
end
return result
end

เหตุการณ์
CaptureBegan
ความสามารถ: Capture
CaptureService.CaptureBegan(captureType:Enum.CaptureType):RBXScriptSignal
พารามิเตอร์
captureType:Enum.CaptureType

CaptureEnded
ความสามารถ: Capture
CaptureService.CaptureEnded(captureType:Enum.CaptureType):RBXScriptSignal
พารามิเตอร์
captureType:Enum.CaptureType

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

UserCaptureSaved
ความสามารถ: Capture
CaptureService.UserCaptureSaved(captureContentId:ContentId):RBXScriptSignal
พารามิเตอร์
captureContentId:ContentId

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ