Class
CaptureService
NotCreatableService
A service which provides control over screenshot and video capture features.
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 | Takes a screenshot and provides a temporary contentId to identify it. |
| CheckUploadCaptureStatusAsync | Polls the status of an in-progress capture upload started by
StartUploadCaptureAsync().Yields |
| PromptCaptureGalleryPermissionAsync | Prompts the user for permission to access their local capture gallery.Yields |
| PromptSaveCapturesToGallery | Prompts the user to save specified captures to their gallery. |
| PromptShareCapture | Prompts the user to share a specified capture. |
| ReadCapturesFromGalleryAsync | Returns a paginated list of captures from the user's gallery.Yields |
| StartUploadCaptureAsync | Begins uploading a capture to the asset system and returns a token used to poll the upload's status.Yields |
| StartVideoCaptureAsync | Initiates a video capture recording.Yields |
| StopVideoCapture | Ends a video capture initiated by
StartVideoCaptureAsync(). |
| TakeScreenshotCaptureAsync | Initiates a screenshot capture. |
| UploadCaptureAsync | Uploads a capture to the asset system and returns the result and asset ID.Yields |
CaptureScreenshot(onCaptureReady: Function): ()#
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 contentId is created to identify the new capture.
Note that any screenshots taken by this method will not be accessible via
ReadCapturesFromGalleryAsync()
or be uploadable via
UploadCaptureAsync().
The onCaptureReady callback can be used to prompt the user to save or
share the screenshot:
| Name | Type | Default | Description |
|---|---|---|---|
onCaptureReady | Function | A callback function that is called with the contentId of the new
capture once it is ready. |
Returns
()
CheckUploadCaptureStatusAsync(token: string): Tuple#
Yields
Client-side function that checks the status of a capture upload started
with
StartUploadCaptureAsync(),
using the returned token. Returns a tuple of the current
UploadCaptureResult and, once the upload finishes successfully, the
asset ID of the uploaded capture.
Poll until a terminal state. While processing, the result is
UploadCaptureResult.UploadPending and the asset ID is 0.
UploadCaptureResult.Success includes the final asset ID;
UploadCaptureResult.CaptureModerated means moderation rejected the
capture; UploadCaptureResult.UploadFailed means the upload did not
complete.
| Name | Type | Default | Description |
|---|---|---|---|
token | string | The token returned by
StartUploadCaptureAsync()
that identifies the in-progress upload. |
Returns
Tuple— Tuple of (result:UploadCaptureResult, assetId:number)
PromptCaptureGalleryPermissionAsync(captureGalleryPermission: CaptureGalleryPermission): boolean#
Yields
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 ReadCapturesFromGalleryAsync and UploadCaptureAsync,
as both of these require gallery permissions to work.
| Name | Type | Default | Description |
|---|---|---|---|
captureGalleryPermission | CaptureGalleryPermission | An CaptureGalleryPermission representing the type of access for
which the user will be prompted. |
Returns
boolean— A boolean representing whether or not the user has allowed access to their captures.
PromptSaveCapturesToGallery(captures: Array, resultCallback: Function): ()#
This method prompts the user to save the captures identified by the
provided contentIds or Capture objects to their Captures
gallery within the experience's main menu.
| Name | Type | Default | Description |
|---|---|---|---|
captures | Array | An array of content IDs and/or Capture objects. | |
resultCallback | Function | A callback function that will be invoked with a dictionary mapping
each contentId and/or Capture object to a boolean indicating
if the user accepted saving that capture. |
Returns
()
ReadCapturesFromGalleryAsync(captureTypeFilters: Array = {}, readFromAllEligibleExperiences: boolean = false): Tuple#
Yields
This client-side function returns a paginated list of captures from the
user's gallery as a CapturesPages object sorted
reverse-chronologically, which can be used to iterate through the
captures. The results can be filtered by capture type with the
captureTypeFilters parameter. If this parameter isn't provided, the
function returns all captures.
If readFromAllEligibleExperiences is true, captures from all eligible
experiences will be read. If false, only those from the current
experience will be read. Additionally, captures taken with
CaptureScreenshot() and
subsequently saved with
PromptSaveCapturesToGallery()
will not be returned by this method.
| Name | Type | Default | Description |
|---|---|---|---|
captureTypeFilters | Array | {} | An array of CaptureType. |
readFromAllEligibleExperiences | boolean | false | A boolean; default is false. |
Returns
Tuple— Tuple of (result:ReadCapturesFromGalleryResult, capturesPages:CapturesPages)
StartUploadCaptureAsync(capture: Capture): Tuple#
Yields
Client-side function that begins uploading a Capture (for example,
one from
ReadCapturesFromGalleryAsync())
to the asset system. Unlike
UploadCaptureAsync(), which
blocks until the asset is created, this returns as soon as the upload
starts with a tuple of UploadCaptureResult and a token string.
Use this when the user might leave before the upload finishes; a pending
UploadCaptureAsync is lost if the player leaves. Pass the token to
CheckUploadCaptureStatusAsync()
to poll for completion and the resulting asset ID.
The user must grant gallery access through
PromptCaptureGalleryPermissionAsync();
without it, the result is UploadCaptureResult.NeedPermission. The
capture must be eligible and present in the gallery. Uploads are
rate-limited per user and return
UploadCaptureResult.UploadQuotaReached when exceeded.
Returns
Tuple— Tuple of (result:UploadCaptureResult, token:string)
StartVideoCaptureAsync(onCaptureReady: Function, captureParams: Dictionary = nil): VideoCaptureStartedResult#
Yields
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 onCaptureReady callback can be used to prompt the user to save or
share the video capture.
The captureParams parameter is currently non-operational.
| Name | Type | Default | Description |
|---|---|---|---|
onCaptureReady | Function | A callback function that is called on video capture completion with a
VideoCaptureResult and, if successful, a VideoCapture. | |
captureParams | Dictionary | nil | A dictionary of optional parameters that modify capture behavior. Currently non-operational. |
Returns
VideoCaptureStartedResult— AVideoCaptureStartedResultindicating whether the video recording started successfully.
StopVideoCapture(): ()#
This method ends a video capture that was started by the
StartVideoCaptureAsync()
method.
Returns
()
TakeScreenshotCaptureAsync(onCaptureReady: Function, captureParams: Dictionary = nil): ()#
This method initiates a screenshot capture. The onCaptureReady callback
can be used to prompt the user to save or share the screenshot capture.
Use the UICaptureMode parameter in captureParams to specify
whether UI elements should be in the screenshot. By default, this is set
to UICaptureMode.None.
| Name | Type | Default | Description |
|---|---|---|---|
onCaptureReady | Function | A callback function that is called on screenshot capture completion
with a ScreenshotCaptureResult and, if successful, a
ScreenshotCapture. | |
captureParams | Dictionary | nil | A dictionary that modifies capture behavior. |
Returns
()
UploadCaptureAsync(capture: Capture): Tuple#
Yields
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.
Returns
Tuple— Tuple of (result:UploadCaptureResult, assetId:number)
Events 4#
| CaptureBegan | Fires immediately before a capture begins. |
| CaptureEnded | Fires after a capture finishes. |
| CaptureSaved | Fires when a screenshot capture is saved to the user's gallery.Deprecated |
| UserCaptureSaved | Fires when the user saves a capture. |
CaptureBegan(captureType: CaptureType)#
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.
| Name | Type | Default | Description |
|---|---|---|---|
captureType | CaptureType | An CaptureType indicating whether the capture is a screenshot
or video. |
CaptureEnded(captureType: CaptureType)#
This event fires after a new capture completes. It can be used to restore
any changes made when the CaptureBegan
event fired.
| Name | Type | Default | Description |
|---|---|---|---|
captureType | CaptureType | An CaptureType indicating whether the capture was a screenshot
or video. |
CaptureSaved(captureInfo: Dictionary)#
DeprecatedDeprecated
Deprecated. This event has been superseded by the
UserCaptureSaved event.
Fires when a screenshot capture is saved to the user's gallery. Provides a
captureInfo dictionary with contentId, filePath, and type. Fires
only for screenshot captures, not video captures.
Deprecated; use UserCaptureSaved
instead, which fires with the saved capture's contentId directly.
| Name | Type | Default | Description |
|---|---|---|---|
captureInfo | Dictionary | A dictionary containing contentId, filePath, and type fields
describing the saved capture. |
UserCaptureSaved(captureContentId: ContentId)#
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.
| Name | Type | Default | Description |
|---|---|---|---|
captureContentId | ContentId | The contentId identifying the screenshot that the user saved. |
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild