Function return lagging everything

I’m making a RoFNF game (go figure), and I made a custom AnimatedSprite class to handle animated image labels. The game keeps lagging at the return keyword of the .new function. I added a task.wait() and it works, but it drastically slows down loading times. How can I prevent this lag?

local Signal = require(game.ReplicatedStorage.Modules.Utility.Signal)
local XMLDecode = require(game.ReplicatedStorage.Modules.Utility.XMLDecode)
local GuiImage = require(game.ReplicatedStorage.Modules.GameClasses.GuiImage)

AnimatedSprite = {}
AnimatedSprite.__index = AnimatedSprite
setmetatable(AnimatedSprite,GuiImage)


function AnimatedSprite.new(parent, imageUrl, json)
	local newAnimatedSprite = GuiImage.new(imageUrl,parent)
	setmetatable(newAnimatedSprite,AnimatedSprite)

	--newAnimatedSprite.Label = Instance.new("ImageLabel")
	--newAnimatedSprite.Label.Parent = parent
	--newAnimatedSprite.Label.Image = imageUrl
	newAnimatedSprite.ImageLabel.Transparency = 1
	
	newAnimatedSprite.AnimationData = json
	--print(newAnimatedSprite.AnimationData)
	
	return newAnimatedSprite
end

function AnimatedSprite:PlayAnim(animInfo)
	print("hello")
	--[[for i = 1, #animInfo do
		local animInfoThisFrame = animInfo[i]

		--local frameSize = animInfoThisFrame.frameSize
		--containingFrame.Size = UDim2.fromOffset(frameSize.X, frameSize.Y)

		local size = animInfoThisFrame.size
		self.Label.ImageRectSize = size
		self.Label.ImageRectOffset = animInfoThisFrame.topLeftCorner

		self.Label.Size = UDim2.fromOffset(size.X, size.Y)

		local imageOffset = -animInfoThisFrame.frameOffset -- we want to inverse due to our hierarchy
		self.Label.Position = UDim2.fromOffset(imageOffset.X, imageOffset.Y)

		task.wait(.1)
	end]]
end

return AnimatedSprite

Sorry, where is the lag being created?