Turn screenshots into teleporting paintings

Create teleporting paintings from screenshots using CaptureService and EditableImage!

:camera_flash: This resource walks through taking a screenshot in-experience, adding it to the world as a “painting”, and modifying the pixels at runtime. In the demo, you can even walk up to the painting and warp to the original location the screenshot was taken :framed_picture:

I made this resource because I heard feedback that some creators were struggling with using and combining CaptureService and EditableImage APIs. If you’re interested at all, check out the demo, take a look at the guide, or even just grab the complete LocalScript below! Leave a comment if you have any additional questions or suggestions.

What you’ll learn

  1. :camera: Take a screenshot with CaptureService and remember where it was taken
  2. :floppy_disk: Save to the gallery and get a ContentId for the capture
  3. :up_arrow: Load the ContentId into an EditableImage
  4. :pinching_hand: Downscale into a working image so per-pixel effects stay fast
  5. :tv: Show it in a UI element with ImageLabel.ImageContent
  6. :notebook_with_decorative_cover: Edit the pixels with buffers: a linear wave and a circular ripple
  7. :framed_picture: Build the picture frame with a SurfaceGui and a UIPageLayout
  8. :ocean: Subtle ripples as you approach the painting
  9. :door: Jump in with a ProximityPrompt
  10. :clapper_board: The cutscene: scripting the Camera and making the player jump through the picture
  11. :tornado: The warp: Teleport back to where the screenshot was taken

Plus :megaphone: (Optional) Publishing a capture with UploadCaptureAsync

Everything runs in a single LocalScript in StarterPlayerScripts. The picture frame is created on the client, so only the local player sees it. That’s fine for a demo; for a shared experience you might want to build the frame on the server and let each client edit its own image.


Before you start

  • CaptureService capture APIs are client-side. Use a LocalScript.
  • Taking a screenshot does not publish it. Captures taken through Roblox’s built-in capture UI are published, but captures you take from a script stay local to the player’s gallery until the player publishes them. A capture can be uploaded with CaptureService:UploadCaptureAsync(capture: Capture)
  • Saving a capture to the gallery needs the player’s permission, which you request with PromptCaptureGalleryPermissionAsync.

How to read the steps: each step shows the part of the script that matters for that idea, not a complete program. Snippets define functions that later steps call and use variables that are set up elsewhere, so pasting them one by one into a LocalScript won’t run on its own (you’ll hit errors like “Expected Object, got nil”).

To follow along in Studio, grab EditableImageCaptureDemo.client.lua from the bottom of this post, drop it in StarterPlayerScripts, and read each step alongside the matching section of the script.

Step 1: Take a screenshot

CaptureService:TakeScreenshotCaptureAsync() takes a callback that receives a ScreenshotCaptureResult and a Capture object. The second argument is a parameter table; UICaptureMode = Enum.UICaptureMode.None leaves your own UI out of the picture (see UICaptureMode).

The “warp” part of the demo needs to know where the player was standing, so grab the character’s CFrame at the moment of the screenshot.

local CaptureService = game:GetService("CaptureService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer

local pendingCapture: Capture? = nil
local pendingDestination: CFrame? = nil -- where the player stood

local function takeScreenshot()
	local character = player.Character
	local root = character and character:FindFirstChild("HumanoidRootPart") :: BasePart?
	if not root then
		return
	end
	local destination = root.CFrame

	-- UICaptureMode.None keeps our own UI out of the screenshot
	CaptureService:TakeScreenshotCaptureAsync(function(result: Enum.ScreenshotCaptureResult, capture: Capture?)
		if result ~= Enum.ScreenshotCaptureResult.Success or not capture then
			warn("Screenshot failed: " .. result.Name)
			return
		end
		pendingCapture = capture
		pendingDestination = destination
	end, { UICaptureMode = Enum.UICaptureMode.None })
end

Alternative: Use built-in capture controls

You don’t have to add your own screenshot button. Roblox’s built-in capture UI lets players take screenshots themselves, and CaptureService fires events you can listen to:

  • CaptureBegan fires when a capture starts.
  • CaptureEnded fires when the capture finishes.
  • UserCaptureSaved fires when the player saves a screenshot from the capture UI, and passes the ContentId of that screenshot.

Record the CFrame in CaptureBegan, then pair it with the saved screenshot’s ContentId in UserCaptureSaved:

local CaptureService = game:GetService("CaptureService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer

local pendingDestination: CFrame? = nil
local pendingContentId: string? = nil

local function getCharacterCFrame(): CFrame?
	local character = player.Character
	local root = character and character:FindFirstChild("HumanoidRootPart") :: BasePart?
	return if root then root.CFrame else nil
end

CaptureService.CaptureBegan:Connect(function()
	-- Snapshot where the player is standing as the capture starts
	pendingDestination = getCharacterCFrame()
end)

CaptureService.UserCaptureSaved:Connect(function(captureContentId: string)
	-- The player kept the screenshot: link it to the position we recorded
	pendingContentId = captureContentId
	print("Saved", captureContentId, "taken at", pendingDestination)
end)

CaptureService.CaptureEnded:Connect(function()
	-- Capture UI closed. If nothing was saved, discard the stored position.
	if not pendingContentId then
		pendingDestination = nil
	end
end)

Step 2: Save to the gallery and get a ContentId

Two calls here:

Saving a capture fires CaptureService.UserCaptureSaved with a ContentId. That ContentId is what we load into the EditableImage in the next step, so store it.

local lastContentId = nil -- set by UserCaptureSaved

CaptureService.UserCaptureSaved:Connect(function(captureContentId)
	lastContentId = captureContentId
end)

local function ensureGalleryPermission(): boolean
	local ok, granted = pcall(function()
		return CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
	end)
	return ok and granted == true
end

local function saveToGallery(capture: Capture): boolean
	if not ensureGalleryPermission() then
		return false
	end

	local saved = false
	local done = false
	CaptureService:PromptSaveCapturesToGallery({ capture }, function(results)
		saved = results[capture] == true
		done = true
	end)
	while not done do
		task.wait()
	end
	return saved
end

Step 3: Load the ContentId into an EditableImage

AssetService:CreateEditableImageAsync() takes a Content value. Build one from the ContentId with Content.fromUri().

local AssetService = game:GetService("AssetService")

local function loadCaptureIntoEditableImage(): EditableImage?
	if lastContentId == nil then
		warn("No ContentId yet. UserCaptureSaved fires when the capture is saved to the gallery.")
		return nil
	end

	local ok, result = pcall(function()
		return AssetService:CreateEditableImageAsync(Content.fromUri(tostring(lastContentId)))
	end)
	if not ok then
		warn("Loading the capture failed: " .. tostring(result))
		return nil
	end
	return result
end

:woman_gesturing_no: Passing the Capture object itself with Content.fromObject(capture) doesn’t work. CreateEditableImageAsync errors with “Object is expected to be an EditableImage”. Use the ContentId from UserCaptureSaved instead.


Step 4: Downscale into a working image

A full-resolution screenshot is a lot of pixels to loop over in Luau. Create a smaller EditableImage with AssetService:CreateEditableImage(), draw the capture into it scaled down with DrawImageTransformed(), then Destroy() the full-size source to free memory.

PivotPoint = Vector2.zero pins the top-left corner of the source to the destination position, and Enum.ImageCombineType.Overwrite replaces the destination pixels (see ImageCombineType).

local MAX_WORK_SIZE = Vector2.new(400, 240)

local function makeWorkImage(source: EditableImage): EditableImage
	local scale = math.min(MAX_WORK_SIZE.X / source.Size.X, MAX_WORK_SIZE.Y / source.Size.Y, 1)
	local workSize = Vector2.new(
		math.max(1, math.floor(source.Size.X * scale)),
		math.max(1, math.floor(source.Size.Y * scale))
	)

	local workImage = AssetService:CreateEditableImage({ Size = workSize })
	workImage:DrawImageTransformed(Vector2.zero, Vector2.new(scale, scale), 0, source, {
		CombineType = Enum.ImageCombineType.Overwrite,
		PivotPoint = Vector2.zero,
	})
	source:Destroy()
	return workImage
end

:framed_picture: Toeing the line between efficiency and resolution
Its a best practice to load the closest-size-but-still-bigger-than-rendered image when showing images to users. Losing resolution is great for efficiency but make sure you still get the resolution you want. If you show this image in a bigger space, consider compressing it less.


Step 5: Show it in a UI element

An EditableImage is displayed by pointing a UI element’s ImageContent at it. ImageLabel.ImageContent takes a Content, and Content.fromObject() wraps the EditableImage.

In addPainting

local page = Instance.new("ImageLabel")
page.Size = UDim2.fromScale(1, 1)
page.ImageContent = Content.fromObject(workImage)

After that, any edit you make to workImage shows up on the label.


Step 6: Edit the pixels

ReadPixelsBuffer() returns a buffer of RGBA bytes (4 bytes per pixel, row by row), and WritePixelsBuffer() writes one back.

Moving whole pixels around is easiest with 32-bit reads and writes (buffer.readu32 / buffer.writeu32): one call moves a full RGBA pixel. buffer.copy is useful for cloning a buffer natively.

The pattern for any displacement effect:

  1. Take a snapshot of the pixels (ReadPixelsBuffer).
  2. Make a working frame buffer that starts as a copy of the snapshot.
  3. Each frame, for the pixels the effect touches, write snapshot[sourcePixel] into frame[pixel], where sourcePixel is displaced.
  4. Write the frame buffer back with WritePixelsBuffer.

A linear wave

A band travels across the image and shifts the pixels inside it sideways, like a flag. Only the band’s columns are recomputed each frame (plus the previous band, to restore it).

local RunService = game:GetService("RunService")

-- Smooth bump: 1 at the wave's center, 0 at its edges
local function bump(delta: number, halfWidth: number): number
	local t = delta / halfWidth
	local inverse = 1 - t * t
	return inverse * inverse
end

local function sweep(image: EditableImage, amplitude: number, bandHalf: number, speed: number)
	local size = image.Size
	local width, height = size.X, size.Y

	local snapshot = image:ReadPixelsBuffer(Vector2.zero, size)
	local frame = buffer.create(width * height * 4)
	buffer.copy(frame, 0, snapshot)

	local k = math.pi / (bandHalf * 0.5) -- about two crests inside the band
	local totalTime = (width + 2 * bandHalf) / speed

	local elapsed = 0
	local prevFront = -bandHalf
	while true do
		local finished = elapsed >= totalTime
		local front = -bandHalf + speed * elapsed

		-- Columns to recompute: the old band (to restore it) plus the new band
		local first = math.max(0, math.floor(prevFront - bandHalf))
		local last = math.min(width - 1, math.ceil(if finished then prevFront + bandHalf else front + bandHalf))

		for x = first, last do
			local delta = x - front
			local push = 0
			if not finished and math.abs(delta) < bandHalf then
				push = amplitude * bump(delta, bandHalf) * math.sin(delta * k)
			end
			for y = 0, height - 1 do
				local sourceY = if push == 0 then y else math.clamp(math.round(y + push), 0, height - 1)
				buffer.writeu32(frame, (y * width + x) * 4, buffer.readu32(snapshot, (sourceY * width + x) * 4))
			end
		end

		image:WritePixelsBuffer(Vector2.zero, size, frame)

		if finished then
			break
		end
		prevFront = front
		elapsed += RunService.RenderStepped:Wait()
	end
end

RunService.RenderStepped paces the loop to the frame rate.

:water_buffalo: Buffers are very cool and very powerful
Read more from their initial launch in 2023 to see what else they’re used for: Introducing Luau buffer type [Beta]

A circular ripple

Same idea, but the wave is a ring expanding from a center point and pixels are pushed along the radial direction. The core of it:

-- For a pixel (x, y), with the ring center at (cx, cy) and the ring currently at radius `front`:
local dx, dy = x - cx, y - cy
local dist = math.sqrt(dx * dx + dy * dy)
local delta = dist - front

local sourceX, sourceY = x, y
if dist > 0.5 and math.abs(delta) < bandHalf then
	local push = amplitude * bump(delta, bandHalf) * math.sin(delta * k) * fade
	sourceX = math.clamp(math.round(x + dx / dist * push), 0, width - 1)
	sourceY = math.clamp(math.round(y + dy / dist * push), 0, height - 1)
end
-- frame[x, y] = snapshot[sourceX, sourceY]

To keep it fast, only loop over the ring: for each row, work out the horizontal span between the ring’s inner and outer radius with math.sqrt(radius^2 - dy^2), and process just those spans. The full script does this.

Tips for making effects cheap:

  • Downscale first (Step 4).
  • Only recompute the pixels that change, and write once per frame.
  • Restore the previously touched pixels from the snapshot so nothing is left behind.

Step 7: Build the picture frame

Put the EditableImage on a part with a SurfaceGui. Face and Adornee are inherited from SurfaceGuiBase, and SurfaceGuiSizingMode.PixelsPerStud sets its resolution.

A few details that matter:

  • A part’s front face is its -Z side, and CFrame.lookAt points -Z at the target, so CFrame.lookAt(position, target) makes the front face look at target.
  • The SurfaceGui is parented to PlayerGui with Adornee set to the part, and Active = true, so the buttons on it receive input.
  • The canvas part is solid (CanCollide left on), so players can’t walk through it before using the prompt.
local height = 6
local width = height * (workImage.Size.X / workImage.Size.Y) -- match the screenshot's aspect

local facing = CFrame.lookAt(position, Vector3.new(spawnPosition.X, position.Y, spawnPosition.Z))

local canvasPart = Instance.new("Part")
canvasPart.Anchored = true
canvasPart.Color = Color3.new(0, 0, 0)
canvasPart.Size = Vector3.new(width, height, 0.3)
canvasPart.CFrame = facing * CFrame.new(0, 0, -0.3)
canvasPart.Parent = workspace

local surfaceGui = Instance.new("SurfaceGui")
surfaceGui.Face = Enum.NormalId.Front
surfaceGui.Adornee = canvasPart
surfaceGui.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
surfaceGui.PixelsPerStud = 60
surfaceGui.LightInfluence = 0
surfaceGui.ResetOnSpawn = false
surfaceGui.Active = true
surfaceGui.Parent = player:WaitForChild("PlayerGui")

To place the frame at the bottom edge a little above the ground, raycast down with workspace:Raycast() and RaycastParams (with RaycastFilterType.Exclude to ignore the character). To put it near the spawn, look for a SpawnLocation:

local spawnLocation = workspace:FindFirstChildWhichIsA("SpawnLocation", true)

local function findGroundY(position: Vector3): number
	local rayParams = RaycastParams.new()
	rayParams.FilterType = Enum.RaycastFilterType.Exclude
	rayParams.FilterDescendantsInstances = { player.Character }
	local hit = workspace:Raycast(position + Vector3.new(0, 5, 0), Vector3.new(0, -60, 0), rayParams)
	return if hit then hit.Position.Y else position.Y - 3
end

Multiple paintings with a UIPageLayout

Each captured image becomes a page in a UIPageLayout. I used this for simplicity of the demo, because it has paging built in. The demo turns the “bounce” up on purpose (elastic easing, big gaps, circular). The page ImageLabel from Step 5 gets parented to the frame that holds the layout, and JumpTo() shows it.

EasingStyle and EasingDirection control the animation.

local pages = Instance.new("Frame")
pages.Size = UDim2.fromScale(1, 1)
pages.BackgroundTransparency = 1
pages.ClipsDescendants = true
pages.Parent = surfaceGui

local layout = Instance.new("UIPageLayout")
layout.Animated = true
layout.Circular = true
layout.TweenTime = 1.2
layout.EasingStyle = Enum.EasingStyle.Elastic
layout.EasingDirection = Enum.EasingDirection.Out
layout.Padding = UDim.new(0.15, 0)
layout.GamepadInputEnabled = false
layout.ScrollWheelInputEnabled = false
layout.TouchInputEnabled = false
layout.Parent = pages

-- Adding a painting
page.Parent = pages
layout:JumpTo(page)

-- Which painting is showing?
local currentPage = layout.CurrentPage

Media-gallery arrows are two round TextButtons on the SurfaceGui, centered vertically at the left and right edges. They call layout:Previous() and layout:Next():

local function makeArrow(text: string, anchorX: number, offsetX: number): TextButton
	local button = Instance.new("TextButton")
	button.Size = UDim2.fromOffset(72, 72)
	button.AnchorPoint = Vector2.new(anchorX, 0.5)
	button.Position = UDim2.new(anchorX, offsetX, 0.5, 0)
	button.BackgroundColor3 = Color3.fromRGB(20, 20, 26)
	button.BackgroundTransparency = 0.3
	button.TextColor3 = Color3.new(1, 1, 1)
	button.Font = Enum.Font.GothamBold
	button.TextSize = 40
	button.Text = text
	button.ZIndex = 10
	button.Parent = surfaceGui

	local corner = Instance.new("UICorner")
	corner.CornerRadius = UDim.new(0.5, 0)
	corner.Parent = button
	return button
end

makeArrow("<", 0, 20).Activated:Connect(function()
	layout:Previous()
end)
makeArrow(">", 1, -20).Activated:Connect(function()
	layout:Next()
end)

Step 8: Subtle ripples as you approach

Check the player’s position in the canvas’s local space. Local -Z is in front of the painting, so a player in front has a negative Z. When they’re in range, start a gentle linear sweep every second or so.

local localPos = canvasPart.CFrame:PointToObjectSpace(root.Position)
local near = math.abs(localPos.X) < halfWidth + 4
	and math.abs(localPos.Y) < halfHeight + 4
	and localPos.Z < 0
	and localPos.Z > -NEAR_DISTANCE

Don’t start a new ripple while one is running (the demo keeps a rippling flag on each painting).

:light_bulb: Use ProximityPrompts for cheap range checks
Instead of checking the player’s position on RenderStepped, you can easily listen to events fired by ProximityPrompt to see if a player is within range of an object. The PromptShown and PromptHidden events still fire if you set the Style to ProximityPromptStyle.Custom (leaving you to create – or leave out – the UI yourself!)


Step 9: Jump in with a ProximityPrompt

ProximityPrompt handles the range check and shows Roblox’s prompt UI. Parent it to the canvas part; MaxActivationDistance is the range, and Triggered fires when the player completes the hold.

local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.ActionText = "Jump in"
proximityPrompt.ObjectText = "Painting"
proximityPrompt.HoldDuration = 0.4
proximityPrompt.MaxActivationDistance = 10
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.Parent = canvasPart

proximityPrompt.Triggered:Connect(function(playerWhoTriggered)
	if playerWhoTriggered ~= player then
		return
	end
	startCutscene()
end)

:woman_in_lotus_position: ProximityPrompts are easy to shift around vertically
If you’d like the prompt to show above or below the frame, thats easy to do with ProximityPrompt.UIOffset


Step 10: The cutscene

The cutscene scripts the Camera (CameraType = Enum.CameraType.Scriptable, see CameraType) and moves the character with PivotTo(). It has four beats:

  1. Line up: slide the character onto the line through the painting’s center, perpendicular to the painting, while the camera swings in behind it.
  2. Jump: a straight line to the center, with a jump arc added on top.
  3. Impact: a big circular ripple from the center of the image, a camera dolly with a little shake, an FOV zoom, then a white flash.
  4. Warp: teleport the character and hand the camera back. That’s Step 11.

A small helper drives each beat. It runs a callback every frame with an alpha from 0 to 1:

local function animate(duration: number, step: (number) -> ())
	local t = 0
	while t < duration do
		t += RunService.RenderStepped:Wait()
		step(math.min(t / duration, 1))
	end
	step(1)
end

local function smooth(a: number): number
	return a * a * (3 - 2 * a)
end

Setup

The dive goes straight through the center of the painting. The canvas part’s LookVector points out of its front face (toward the player), so the direction into the painting is its negative. The jump starts at the distance you are from the painting now, slid sideways onto the center line.

local camera = workspace.CurrentCamera
local originalFov = camera.FieldOfView

local entryWorld = canvasPart.Position
local imageSize = painting.image.Size
local entryPx = Vector2.new(imageSize.X / 2, imageSize.Y / 2) -- ripple origin, in image pixels

local normal = canvasPart.CFrame.LookVector
local flatDir = -Vector3.new(normal.X, 0, normal.Z).Unit -- into the painting
local up = Vector3.new(0, 1, 0)

local fromCenter = root.Position - entryWorld
local distance = math.clamp(fromCenter:Dot(-flatDir), 5, PROMPT_RANGE + 4)
local start = Vector3.new(entryWorld.X, root.Position.Y, entryWorld.Z) - flatDir * distance
local original = root.Position

-- Take over: freeze the character in place and script the camera
root.Anchored = true
camera.CameraType = Enum.CameraType.Scriptable

local function cameraBehind(pos: Vector3, cameraDistance: number): CFrame
	return CFrame.lookAt(pos - flatDir * cameraDistance + up * 2.5, entryWorld)
end

Beat 1: line up and swing the camera

local startCamera = camera.CFrame
animate(0.6, function(a)
	local e = smooth(a)
	local pos = original:Lerp(start, e)
	character:PivotTo(CFrame.lookAt(pos, pos + flatDir))
	camera.CFrame = startCamera:Lerp(cameraBehind(start, 7), e)
end)

Beat 2: the jump

Horizontal travel is linear, and the arc’s peak is shifted late so it reads as a real jump rather than something perfectly symmetric. The exponent trick makes the parabola peak exactly at PEAK_AT:

local JUMP_HEIGHT = 3.5
local PEAK_AT = 0.62
local peakExponent = math.log(0.5) / math.log(PEAK_AT)

animate(1.0, function(a)
	local pos = start:Lerp(entryWorld, a)
	local p = a ^ peakExponent -- reaches 0.5 exactly when a == PEAK_AT
	pos += up * (4 * p * (1 - p) * JUMP_HEIGHT)

	character:PivotTo(CFrame.lookAt(pos, pos + flatDir))
	camera.CFrame = cameraBehind(pos, 7)
	camera.FieldOfView = originalFov + (50 - originalFov) * smooth(a)
end)

Beat 3: impact

Kick off the big ripple from the center (it yields, so run it in its own thread), keep sinking the character into the painting, dolly the camera in with a little shake, zoom the FOV, and start fading to white near the end. flash is the full-screen frame from the next step.

task.spawn(bigRipple, painting, entryPx.X, entryPx.Y)

animate(1.1, function(a)
	local e = smooth(a)
	local pos = entryWorld + flatDir * (e * 4)
	character:PivotTo(CFrame.lookAt(pos, pos + flatDir))

	local camPos = entryWorld - flatDir * (7 - 5 * e) + up * (2.5 * (1 - e))
	local shake = 0.18 * (1 - a)
	local shakeOffset = Vector3.new((math.random() - 0.5) * shake, (math.random() - 0.5) * shake, 0)
	camera.CFrame = CFrame.lookAt(camPos + shakeOffset, entryWorld)
	camera.FieldOfView = 50 + (25 - 50) * e

	if a > 0.65 then
		flash.BackgroundTransparency = 1 - (a - 0.65) / 0.35
	end
end)

The big ripple is the same circular ripple from Step 6 with much larger numbers (a wide ring, a big amplitude, and a radius that covers the whole image). It waits for any gentle sweep to finish first, or you can end the sweep early when the cutscene starts.


Step 11: The warp

By now the screen is fully white, so the teleport is hidden. The warp itself is short:

  1. PivotTo the character to the CFrame you saved at screenshot time (Step 1). Each painting stores its own destination, so you warp to wherever that painting was taken.
  2. Give the camera back by setting CameraType to Custom, and restore the field of view.
  3. Unanchor the root part.
  4. Fade the flash back out.

First, the full-screen flash overlay (a white Frame that’s fully transparent until needed):

local flashGui = Instance.new("ScreenGui")
flashGui.Name = "WarpFlash"
flashGui.ResetOnSpawn = false
flashGui.IgnoreGuiInset = true
flashGui.DisplayOrder = 100
flashGui.Parent = player:WaitForChild("PlayerGui")

local flash = Instance.new("Frame")
flash.Size = UDim2.fromScale(1, 1)
flash.BackgroundColor3 = Color3.new(1, 1, 1)
flash.BackgroundTransparency = 1
flash.BorderSizePixel = 0
flash.Parent = flashGui

Then the warp, which runs right after the impact beat:

-- Screen is white: warp
character:PivotTo(painting.destination)
camera.CameraType = Enum.CameraType.Custom
camera.FieldOfView = originalFov
root.Anchored = false

-- Fade back in at the destination
animate(0.7, function(a)
	flash.BackgroundTransparency = smooth(a)
end)

Wrapping it all up safely

Run the whole cutscene inside a pcall and put the “give control back” code after it, so a bug can’t leave the player frozen or stuck in a scripted camera. Also disable the prompt while it plays and add a short cooldown, so the player can’t trigger it twice.

local warping = false
local cooldownUntil = 0

local function onTriggered(playerWhoTriggered: Player)
	if playerWhoTriggered ~= player or warping or os.clock() < cooldownUntil then
		return
	end

	-- Extra range check on top of the prompt's own MaxActivationDistance
	if (root.Position - canvasPart.Position).Magnitude > PROMPT_RANGE + 4 then
		return
	end

	warping = true
	proximityPrompt.Enabled = false

	task.spawn(function()
		local ok, err = pcall(runCutscene, painting, root, canvasPart, character)
		if not ok then
			warn("Cutscene error: " .. tostring(err))
		end

		-- Always give control back, even if something above errored
		root.Anchored = false
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		flash.BackgroundTransparency = 1

		cooldownUntil = os.clock() + 3
		proximityPrompt.Enabled = true
		warping = false
	end)
end

proximityPrompt.Triggered:Connect(onTriggered)

Anything else that touches the painting (like the proximity ripples from Step 8) should check warping and stand down while the cutscene runs.

:camera_flash: Are full screen flashes safe for people with photosensitivity?
The general guidance is that three or fewer flashes per second is ok. Risk also correlates positively with the percentage of the screen that the flash takes up, so the smaller the area that the flash occurs in, the lower the risk. Read more about best practices here: https://www.w3.org/WAI/WCAG22/Understanding/three-flashes-or-below-threshold

Optional: a “Teleport” shortcut

If you also want a button that takes the player to the frame (for example, after they’ve warped away), it’s the same pieces: fade, PivotTo to a spot in front of the frame, fade back.

local function teleportToFrame()
	warping = true
	local groundY = canvasPart.Position.Y - FRAME_HEIGHT / 2 - FRAME_LIFT
	local front = canvasPart.CFrame.LookVector * 10
	local target = Vector3.new(canvasPart.Position.X + front.X, groundY + 3, canvasPart.Position.Z + front.Z)
	local facing = CFrame.lookAt(target, Vector3.new(canvasPart.Position.X, target.Y, canvasPart.Position.Z))

	animate(0.25, function(a)
		flash.BackgroundTransparency = 1 - a
	end)
	character:PivotTo(facing)
	animate(0.4, function(a)
		flash.BackgroundTransparency = a
	end)
	flash.BackgroundTransparency = 1
	warping = false
end

:chair: Sitting prevents PivotTo from modifying a player’s position
If, like me, you wanted to take a cute photo sitting down and then teleport to the photo frame, you’ll notice that your character will be stuck in their comfy seat. Can you think of a way to avoid this problem?

Optional: Publishing a capture

Captures taken from scripts aren’t published. CaptureService:UploadCaptureAsync() uploads a capture from the player’s gallery to the asset system and returns an UploadCaptureResult plus an asset ID. It needs gallery permission, and the capture should already be in the gallery (Step 2).

local function publishCapture(capture: Capture): number?
	if not ensureGalleryPermission() then
		return nil
	end

	local ok, uploadResult, assetId = pcall(function()
		return CaptureService:UploadCaptureAsync(capture)
	end)

	if not ok then
		warn("UploadCaptureAsync error: " .. tostring(uploadResult))
		return nil
	end
	if uploadResult ~= Enum.UploadCaptureResult.Success then
		warn("Publish failed: " .. (uploadResult :: Enum.UploadCaptureResult).Name)
		return nil
	end
	return assetId
end

You don’t need to publish for this demo. The painting is built from an in-memory EditableImage, so it works without an asset ID. Publishing would only matter if you want a persistent asset that other players or sessions could load. The demo keeps publishing behind an ENABLE_PUBLISH flag that is off by default. To enable this, you want to ensure that the maturity questionnaire has been complete, and you’re in a live, published game (I had trouble getting this to work in Studio).


Notes and gotchas

  • Use the ContentId from UserCaptureSaved. Content.fromObject(capture) is rejected by CreateEditableImageAsync. The ContentId only exists after the capture has been saved to the gallery.
  • Keep edits cheap. Downscale, recompute only what changed, and write the buffer once per frame.
  • Destroy what you don’t need. Call Destroy() on the full-size source image once you’ve drawn it into the working image.
  • The SurfaceGui lives in PlayerGui (with Adornee set) so its buttons get input.
  • Everything is local. The frame, the image, and the cutscene are client-only here. This allows the demo to be in one script, but for real-world use cases it might be better to split this out.

API reference

Capture

Images

World, frame, and prompt

UI


Full script

Move this LocalScript in StarterPlayer > StarterPlayerScripts.

EditableImageCaptureDemo.client.lua (43.2 KB)

61 Likes

Really awesome resource, thanks for writing this up! :slight_smile:

2 Likes

cool, would be cooler if the user didnt have to upload the image though (because literally no ones doing that)

:goat:

2 Likes

Love this, but is it possible to theoretically make a working mirror with this?
I just realized that might be an extremely unoptimized idea

I forgot what I wanted to do but I know I had wanted to make a screenshot editable a few time ago god damn it

is that gonna be possible>?

3 Likes

This is not what I meant, this requires the user’s input for every little frame and takes longer than actually taking a screenshot.

I meant EditableImage support for non-saved Screenshots, ergo temporary images.

2 Likes