Edukacja
Klasa silnika
CaptureService
Brak możliwości tworzenia
Usługa

*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.


Podsumowanie
Metody
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):()
Członkowie odziedziczeni

Materiały referencyjne dotyczące interfejsów API
Metody
CaptureScreenshot
Możliwości: Capture
CaptureService:CaptureScreenshot(onCaptureReady:function):()
Parametry
onCaptureReady:function
Zwroty
()
Przykłady kodu
Zrób Zrzut Ekranu
local CaptureService = game:GetService("CaptureService")
-- Odniesienie do ImageLabel będącego rodzicem skryptu zawierającego ten kod
local imageLabel = script.Parent
local function onCaptureReady(contentId)
imageLabel.Image = contentId
end
CaptureService:CaptureScreenshot(onCaptureReady)

CheckUploadCaptureStatusAsync
Wynik
Możliwości: Capture
CaptureService:CheckUploadCaptureStatusAsync(token:string):Tuple
Parametry
token:string
Zwroty

PromptCaptureGalleryPermissionAsync
Wynik
Możliwości: Capture
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
Parametry
captureGalleryPermission:Enum.CaptureGalleryPermission
Zwroty
Przykłady kodu
Prośba o zgodę na dostęp do galerii zrzutów
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
-- Proszę o zgodę na dostęp do galerii zrzutów
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
end

PromptSaveCapturesToGallery
Możliwości: Capture
CaptureService:PromptSaveCapturesToGallery(
captures:{any}, resultCallback:function
):()
Parametry
captures:{any}
resultCallback:function
Zwroty
()

PromptShareCapture
Możliwości: Capture
CaptureService:PromptShareCapture(
captureContent:Content, launchData:string, onAcceptedCallback:function, onDeniedCallback:function
):()
Parametry
captureContent:Content
launchData:string
onAcceptedCallback:function
onDeniedCallback:function
Zwroty
()
Przykłady kodu
Zachęta do udostępnienia zrzutu
local CaptureService = game:GetService("CaptureService")
local function onShareAccepted()
print("Zrzut udostępnienia został zaakceptowany!")
end
local function onShareDenied()
print("Zrzut udostępnienia został odrzucony!")
end
local onCaptureReady = function(result, videoCapture)
if videoCapture then
local captureContent = Content.fromObject(videoCapture)
CaptureService:PromptShareCapture(captureContent, "launchData" , onShareAccepted, onShareDenied)
end
end
CaptureService:StartVideoCaptureAsync(onCaptureReady, {})

ReadCapturesFromGalleryAsync
Wynik
Możliwości: Capture
CaptureService:ReadCapturesFromGalleryAsync(
captureTypeFilters:{any}, readFromAllEligibleExperiences:boolean
Parametry
captureTypeFilters:{any}
Wartość domyślna: "{}"
readFromAllEligibleExperiences:boolean
Wartość domyślna: false
Zwroty
Przykłady kodu
Odczytaj zbiory z galerii i przejdź przez strony
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
-- Prawdopodobnie błąd uprawnień, zobacz CaptureService:PromptCaptureGalleryPermissionAsync()
warn("Nie udało się pobrać początkowych zrzutów: " .. result.Name)
return
end
-- Iteruj przez bieżącą stronę
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- Przejdź do następnej strony aż do zakończenia
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
Wynik
Możliwości: Capture
CaptureService:StartUploadCaptureAsync(capture:Capture):Tuple
Parametry
capture:Capture
Zwroty

StartVideoCaptureAsync
Wynik
Możliwości: Capture
CaptureService:StartVideoCaptureAsync(
onCaptureReady:function, captureParams:Dictionary
Parametry
onCaptureReady:function
captureParams:Dictionary
Wartość domyślna: "nil"
Przykłady kodu
Rozpocznij przechwytywanie wideo asynchronicznie
local CaptureService = game:GetService("CaptureService")
local tool = Instance.new("Tool")
tool.Parent = workspace
local onCaptureReady = function(result, videoCapture)
if result ~= Enum.VideoCaptureResult.Success and result ~= Enum.VideoCaptureResult.TimeLimitReached or not videoCapture then
print("Nagrywanie wideo nie powiodło się z powodu:", result)
else
-- Poproś użytkownika o zapisanie przechwytywania wideo w ich galerii
CaptureService:PromptSaveCapturesToGallery({ videoCapture }, function()
print("Przechwytywanie zapisane")
end)
end
end
tool.Activated:Connect(function()
local videoRecordingAllowedResult: Enum.VideoCaptureStartedResult = CaptureService:StartVideoCaptureAsync(onCaptureReady, {})
if videoRecordingAllowedResult ~= Enum.VideoCaptureStartedResult.Success then
print("Nagrywanie wideo nie powiodło się z powodu:", videoRecordingAllowedResult)
end
end)

StopVideoCapture
Możliwości: Capture
CaptureService:StopVideoCapture():()
Zwroty
()

TakeScreenshotCaptureAsync
Możliwości: Capture
CaptureService:TakeScreenshotCaptureAsync(
onCaptureReady:function, captureParams:Dictionary
):()
Parametry
onCaptureReady:function
captureParams:Dictionary
Wartość domyślna: "nil"
Zwroty
()
Przykłady kodu
Zrób zrzut ekranu asynchronicznie
local CaptureService = game:GetService("CaptureService")
local parent = Instance.new("Tool")
parent.Parent = workspace
local onCaptureReady = function(result, screenshotCapture)
if result ~= Enum.ScreenshotCaptureResult.Success or not screenshotCapture then
print("Zrzut ekranu nie powiódł się z powodu:", result)
else
-- Poproś użytkownika o zapisanie zrzutu ekranu w ich galerii
CaptureService:PromptSaveCapturesToGallery({ screenshotCapture }, function(results)
for capture, result in pairs(results) do
if result then
print("Zrzut zapisany")
end
end
end)
end
end
parent.Activated:Connect(function()
CaptureService:TakeScreenshotCaptureAsync(onCaptureReady, { UICaptureMode = Enum.UICaptureMode.All })
end)

UploadCaptureAsync
Wynik
Możliwości: Capture
CaptureService:UploadCaptureAsync(capture:Capture):Tuple
Parametry
capture:Capture
Zwroty
Przykłady kodu
Prześlij zrzut do systemu zasobów
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
-- Obsłuż błąd
return nil
end
return assetId
end)
if not success then
-- Obsłuż błąd
return nil
end
return result
end

Zdarzenia
CaptureBegan
Możliwości: Capture
CaptureService.CaptureBegan(captureType:Enum.CaptureType):RBXScriptSignal
Parametry
captureType:Enum.CaptureType

CaptureEnded
Możliwości: Capture
CaptureService.CaptureEnded(captureType:Enum.CaptureType):RBXScriptSignal
Parametry
captureType:Enum.CaptureType

CaptureSaved
Przestarzałe

UserCaptureSaved
Możliwości: Capture
CaptureService.UserCaptureSaved(captureContentId:ContentId):RBXScriptSignal
Parametry
captureContentId:ContentId

©2026 Roblox Corporation. Nazwa Roblox, logo Roblox oraz hasło „Powering Imagination” należą do naszych zarejestrowanych i niezarejestrowanych znaków towarowych na terenie Stanów Zjednoczonych oraz w innych krajach.