Create non-laggy animated skins?

Hi, so I currently have a system that does this but it’s extremely laggy even when done on the client.

		local function Applyandreturn()

			local Texlist = {}
			for iP , vP in pairs(model:GetChildren()) do

				for i = 1, #Enum.NormalId:GetEnumItems() do
					local Texture = Instance.new('Texture', vP)

					Texture.Face = Enum.NormalId:GetEnumItems()[i]


					Texture.Texture = texture

					table.insert(Texlist, Texture)

				end
			end

			return Texlist
		end

		if RarityToNumber[rarity] >= 5 then
			MythicAnimations.Flow(Applyandreturn())

		else  -- static skin / animated above^
			Applyandreturn()
		end
	end)

The Tweening part is likely causing lag because it is Tweening over 30- 60 different textures as they have to be applied to each face. I’ve seen other games get away with this in performance because it only does it to one part. However, our weapons consist of many. I’m wondering if there was a way to animate said textures without causing lag. I’m currently running an RTX 3080 and a ryzen 9 5900x and losing up to 400 frames/s when the animated skin runs; I could only imagine what this will do to lower-end computer’s performance.

-thanks in advance for any help!

If your game is “Lagging” of which is network performance being lowered, I would recommend preloading these textures with ContentProvider before using. If your game is truely “loosing frames” then I would pay extra attention to why all your client code; that your probably running every frame needs to be somewhat optimized. In the above example I see that you use pairs to iterate over the parts of the model, this is sort of an anti-pattern for client driven code. Instead: replace pairs with next of which next, is faster. Remember to use next when you are dealing with client rendering code.

For your tweenservice problem, you should be able to tween a good amount of things on the client, so it might not even be tweenservice. Check your code for memory leaks and use debug.profilestart() to benchmark what the tweens actually take up performance wise.

I hoped this helped.

i did end up finding a fix for it I don’t remember what I did but its in the script somewhere had something to do with the method of animation and c/s boundary. but thanks, those are some useful tips for debugging next time