CaptureService

Show Deprecated
Not Creatable
Service

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.

Summary

Methods

Events

Properties

Methods

CaptureScreenshot

()

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.

The onCaptureReady callback can be used to prompt the user to save or share the screenshot:


local CaptureService = game:GetService("CaptureService")
-- Reference to an ImageLabel parent of the script containing this code
local imageLabel = script.Parent
local function onCaptureReady(contentId)
imageLabel.Image = contentId
end
CaptureService:CaptureScreenshot(onCaptureReady)

Parameters

onCaptureReady: function

A callback function that is called with the contentId of the new capture once it is ready.


Returns

()

PromptSaveCapturesToGallery

()

This method prompts the user to save the captures identified by the provided contentIds to their Captures gallery within the experience's main menu.

Parameters

captures: Array
resultCallback: function

A callback function that will be invoked with a dictionary mapping each contentId to a boolean indicating if the user accepted saving that capture.


Returns

()

PromptShareCapture

()

This method prompts the user to share the capture identified by the provided contentId using the native share sheet on their device.

The capture is shared along with an invite link to the experience when supported. Not all devices support including both a screenshot or video and an invite link.

The launchData will be available in the launchData field for users who join through the invite link.

To avoid an error when calling this method, first call PolicyService:GetPolicyInfoForPlayerAsync() and check that IsContentSharingAllowed is true in the returned dictionary.

Parameters

captureContent: Content
launchData: string

An optional string to include as launch data in the invite link.

onAcceptedCallback: function

An optional callback function invoked if the user accepts sharing.

onDeniedCallback: function

An optional callback function invoked if the user denies sharing.


Returns

()

StartVideoCaptureAsync

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.


local CaptureService = game:GetService("CaptureService")
local parent = script.Parent
local onCaptureReady = function(result, videoCapture)
if result ~= Enum.VideoCaptureResult.Success and result ~= Enum.VideoCaptureResult.TimeLimitReached or not videoCapture then
print("Video recording failed to complete for reason:", result)
else
-- Prompt the user to save the video capture to their gallery
CaptureService:PromptSaveCapturesToGallery({ videoCapture }, function()
print("Capture saved")
end)
end
end
parent.Activated:Connect(function()
local videoRecordingAllowedResult: Enum.VideoCaptureStartedResult = CaptureService:StartVideoCaptureAsync(onCaptureReady, {})
if videoRecordingAllowedResult ~= Enum.VideoCaptureStartedResult.Success then
print("Video recording failed to start for reason:", videoRecordingAllowedResult)
end
end)

Parameters

onCaptureReady: function
captureParams: Dictionary
Default Value: "nil"

Returns

StopVideoCapture

()

This method ends a video capture that was started by the StartVideoCaptureAsync() method.


Returns

()

TakeCapture

()

Parameters

onCaptureReady: function
captureParams: Dictionary
Default Value: "nil"

Returns

()

Events

CaptureBegan

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.

Parameters

captureType: Enum.CaptureType

CaptureEnded

This event fires after a new capture completes. It can be used to restore any changes made when the CaptureBegan event fired.

Parameters

captureType: Enum.CaptureType

UserCaptureSaved

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.

Parameters

captureContentId: ContentId

The contentId identifying the screenshot that the user saved.