Service · inherits Instance
CaptureService
A service which provides control over screenshot and video capture features.
About CaptureService
CaptureService is a client-side service that allows developers to control
how the screenshot and video capture feature integrates with their
experiences. It can be used to include preset moments where a capture is
automatically taken for a user, and that user can then save, share, or delete
the capture.
Methods 11
CaptureScreenshot
(onCaptureReady: Function) → ()Takes a screenshot and provides a temporarycontentIdto identify it.This method captures a screenshot for the user but does not immediately save it to their Captures gallery within the experience's main menu. Instead, a temporary
contentIdis created to identify the new capture.Note that any screenshots taken by this method will not be accessible via
ReadCapturesFromGalleryAsync()or be uploadable viaUploadCaptureAsync().The
onCaptureReadycallback can be used to prompt the user to save or share the screenshot:CheckUploadCaptureStatusAsync
(token: string) → TupleYieldsPolls the status of an in-progress capture upload started byStartUploadCaptureAsync().Client-side function that checks the status of a capture upload started with
StartUploadCaptureAsync(), using the returnedtoken. Returns a tuple of the currentUploadCaptureResultand, once the upload finishes successfully, the asset ID of the uploaded capture.Poll until a terminal state. While processing, the result is
UploadCaptureResult.UploadPendingand the asset ID is0.UploadCaptureResult.Successincludes the final asset ID;UploadCaptureResult.CaptureModeratedmeans moderation rejected the capture;UploadCaptureResult.UploadFailedmeans the upload did not complete.PromptCaptureGalleryPermissionAsync
(captureGalleryPermission: CaptureGalleryPermission) → booleanYieldsPrompts the user for permission to access their local capture gallery.This client-side function prompts a user for permission to access their local captures. Once they have accepted or rejected the prompt, it returns a boolean representing their choice. This function is a necessary prerequisite to
ReadCapturesFromGalleryAsyncandUploadCaptureAsync, as both of these require gallery permissions to work.PromptSaveCapturesToGallery
(captures: Array, resultCallback: Function) → ()Prompts the user to save specified captures to their gallery.This method prompts the user to save the captures identified by the provided
contentIdsorCaptureobjects to their Captures gallery within the experience's main menu.ReadCapturesFromGalleryAsync
(captureTypeFilters: Array = {}, readFromAllEligibleExperiences: boolean = false) → TupleYieldsReturns a paginated list of captures from the user's gallery.This client-side function returns a paginated list of captures from the user's gallery as a
CapturesPagesobject sorted reverse-chronologically, which can be used to iterate through the captures. The results can be filtered by capture type with thecaptureTypeFiltersparameter. If this parameter isn't provided, the function returns all captures.If
readFromAllEligibleExperiencesistrue, captures from all eligible experiences will be read. Iffalse, only those from the current experience will be read. Additionally, captures taken withCaptureScreenshot()and subsequently saved withPromptSaveCapturesToGallery()will not be returned by this method.StartUploadCaptureAsync
(capture: Capture) → TupleYieldsBegins uploading a capture to the asset system and returns a token used to poll the upload's status.Client-side function that begins uploading a
Capture(for example, one fromReadCapturesFromGalleryAsync()) to the asset system. UnlikeUploadCaptureAsync(), which blocks until the asset is created, this returns as soon as the upload starts with a tuple ofUploadCaptureResultand atokenstring. Use this when the user might leave before the upload finishes; a pendingUploadCaptureAsyncis lost if the player leaves. Pass the token toCheckUploadCaptureStatusAsync()to poll for completion and the resulting asset ID.The user must grant gallery access through
PromptCaptureGalleryPermissionAsync(); without it, the result isUploadCaptureResult.NeedPermission. The capture must be eligible and present in the gallery. Uploads are rate-limited per user and returnUploadCaptureResult.UploadQuotaReachedwhen exceeded.StartVideoCaptureAsync
(onCaptureReady: Function, captureParams: Dictionary = nil) → VideoCaptureStartedResultYieldsInitiates a video capture recording.This method initiates a video capture recording. The recording will continue until the
StopVideoCapture()method is called, or when 30 seconds have passed, whichever comes first. During the video recording, all user voices are muted.The
onCaptureReadycallback can be used to prompt the user to save or share the video capture.The
captureParamsparameter is currently non-operational.StopVideoCapture
() → ()Ends a video capture initiated byStartVideoCaptureAsync().This method ends a video capture that was started by the
StartVideoCaptureAsync()method.TakeScreenshotCaptureAsync
(onCaptureReady: Function, captureParams: Dictionary = nil) → ()Initiates a screenshot capture.This method initiates a screenshot capture. The
onCaptureReadycallback can be used to prompt the user to save or share the screenshot capture.Use the
UICaptureModeparameter incaptureParamsto specify whether UI elements should be in the screenshot. By default, this is set toUICaptureMode.None.UploadCaptureAsync
(capture: Capture) → TupleYieldsUploads a capture to the asset system and returns the result and asset ID.This client-side function uploads a capture, like one retrieved from
ReadCapturesFromGalleryAsync, to the asset system. It returns a tuple of the result and the asset ID.Notes:
- This function will only work properly if the Maturity and Compliance questionnaire has been filled out for the experience.
- For video capture types, there is an upload limit of 20 videos per day
per user; when that limit is exceeded, the result is
UploadCaptureResult.UploadQuotaReached, which lets you distinguish quota exhaustion from other failures. - This function can take up to several minutes to finish executing, and the user will need to remain in the experience.
Events 3
CaptureBegan
CaptureService.CaptureBegan:Connect(function(captureType))Fires immediately before a capture begins.This event fires right before a new capture is taken. It can be used to customize the capture experience, for example by hiding certain GUI elements.
CaptureEnded
CaptureService.CaptureEnded:Connect(function(captureType))Fires after a capture finishes.This event fires after a new capture completes. It can be used to restore any changes made when the
CaptureBeganevent fired.UserCaptureSaved
CaptureService.UserCaptureSaved:Connect(function(captureContentId))Fires when the user saves a capture.This event fires when the user saves a screenshot using the Roblox screenshot capture UI. It can be used for analytics or to prompt the user to share their capture.
CaptureService also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.