local i=""local k=5 local b=3 local O=k*b local a=320 local U=200 local m=11 local I=3 assert((numImages*k)*b>=I)local C=.3 assert(C>0)local d=0 local H=0 local V=I/C local N=0 local function j(i)N=math.fmod(N+i,C)H=math.floor(N*V)+m local k=d d=math.floor(H/O)if k~=d then imageInstance.Image=imageAssetIDs[d+1]end local I=H-d*O local j=math.floor(I/b)local Y=I-j*b imageInstance.ImageRectOffset=Vector2.new(Y*a,j*U)end Animator.Connection=nil Animator.Init=function()Animator.Connection=(game:GetService("\082\117\110\083\101\114\118\105\099\101")).RenderStepped:Connect(j)end Animator.Stop=function()if Animator.Connection then imageInstance.Image=i Animator.Connection:Disconnect()end end return Animator

local initialTexture = ""

local RowCount = 5 
local ColCount = 3
local perImageSpriteCount = RowCount * ColCount
local width = 320
local height = 200
local startIndexOffset = 11

local framesInTotal = 3
assert(numImages * RowCount * ColCount >= framesInTotal)

local animPeriod = 0.3 -- period for the whole animation, in seconds
assert(animPeriod > 0)

local curImageIdx = 0
local curSpriteIdx = 0

local fps = framesInTotal / animPeriod
local accumulatedTime = 0

local function AnimateImageSpriteSheet(dt)
	accumulatedTime = math.fmod(accumulatedTime + dt, animPeriod)
	curSpriteIdx = math.floor(accumulatedTime * fps) + startIndexOffset

	local prevImageIndex = curImageIdx
	curImageIdx = math.floor(curSpriteIdx / perImageSpriteCount)
	if prevImageIndex ~= curImageIdx then
		imageInstance.Image = imageAssetIDs[curImageIdx + 1]
	end

	local localSpriteIndex = curSpriteIdx - curImageIdx * perImageSpriteCount
	local row = math.floor(localSpriteIndex / ColCount)
	local col = localSpriteIndex - row * ColCount
	imageInstance.ImageRectOffset = Vector2.new(col * width, row * height)
end

Animator.Connection = nil

Animator.Init = function()
	Animator.Connection = game:GetService("RunService").RenderStepped:Connect(AnimateImageSpriteSheet)
end

Animator.Stop = function()
	if Animator.Connection then
		imageInstance.Image = initialTexture
		Animator.Connection:Disconnect()
	end
end


return Animator
