What is the most effecient way to loop this?

https://gyazo.com/fe134f1c5dc0640a4cce66e578be4852

for each basepart i am creating a decal and tweening its transparency,
(about 180 tweens at a time)

it causes quite a bit of lag and it shows in the microprofiler,

i have alredy tried
-tweening each individual decal
-tweening a number value and making a listener to each decal
-renderstepped loop that loops through an array of all the decals

all of which causes the same yield of lag.

		for _,child in pairs(character:GetDescendants()) do
			if child:IsA("BasePart") and not(child.Name == "HumanoidRootPart") then
				
				for _,face in pairs(faceLoop) do
					print("tween")
					local decal = Decal:Clone()
					decal.Face = face
					decal.Parent = child
					
					local tween = tweenService:Create(decal,TweenInfo.new(6),{Transparency = 0})
					tween:Play()
					game.Debris:AddItem(decal,10)
				end
			end
		end
1 Like

Are you doing this in a server script, or a local script?
Usually, high intensity loops lag on the server, since the processing power is smaller.

Local loops usually give smoother effects. If you are already using a Local Script to do these animations, I would recommend avoid using Tweens (a lot of overhead, just for tweening transparency) and instead use the RunService’s RenderStepped.

1 Like

yes im doing it client sided. and i alredy tried renderstepped loops.

1 Like

You should use coroutines or task.spawn to prevent main thread yielding and destroy the Tween object after it finished tweeting, that should reduce lag.

1 Like