This is the code sample I am referring to:
local CaptureService = game:GetService("CaptureService")
local function readCapturesFromGallery()
local allCaptures = {}
local capturesPages
local success, result = pcall(function()
local readResult, pages = CaptureService:ReadCapturesFromGalleryAsync()
if readResult == Enum.ReadCapturesFromGalleryResult.Success then
capturesPages = pages
end
return readResult
end)
if not success or result ~= Enum.ReadCapturesFromGalleryResult.Success then
warn("Failed to fetch initial captures: " .. result)
return
end
-- Iterate through current page
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- Advance to next page until finished
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
When I run it in a game this line errors:
warn("Failed to fetch initial captures: " .. result)
–attempt to concatenate string with EnumItem
Fix:
warn("Failed to fetch initial captures: " .. result.Name)
Page URL: https://create.roblox.com/docs/reference/engine/classes/CaptureService#ReadCapturesFromGalleryAsync