I’ve been currently try to use CaptureService to create a lot of cool visual effects, especially when it comes to stuff like flashbangs and such, but one thing I find very odd is that is very inconsistent and it doesn’t seem to work in an actual game? I was hoping someone would clear up the confusion.
`self.CurrentFrame = nil
local RETRY = 5
local function CaptureScreen()
local ResultImageScreen = nil
CaptureService:CaptureScreenshot(function(ImageId)
ResultImageScreen = ImageId
end)
local Tried = 0
while not ResultImageScreen or Tried > RETRY do
Tried += 1
task.wait(0.5)
end
return ResultImageScreen
end
coroutine.wrap(function()
while task.wait(1) do
self.CurrentFrame = CaptureScreen()
end
end)()`
(for clarification, the client constantly tries to take a photo during runtime to use whenever the player gets flashbanged.)
Would you be able to clarify a bit more? Are the images actually being captured or do all of them fail? Additionally, perhaps try adding a print(ImageId) to check
Also, a better way to format your function would be like this:
local function CaptureScreen()
local thread = coroutine.running()
CaptureService:CaptureScreenshot(function(ImageId)
task.spawn(thread, ImageId)
end)
return coroutine.yield()
end
This will yield your script and return the image id as soon as it’s available instead of using a while loop to check.
Its very inconsistent, the images SOMETIMES get captured, or they straight up don’t sometimes, its always one or the other, but i will try your method as well, thank you!