I like to use loops to give certain effects to parts in my game. For example, when a player double jumps, a little shockwave comes from their feet and grows outwards and then fades away. This has been working fine until about a week ago. No matter how old a server is, these effects are always laggy. They rotate and expand way too slow, sometimes the loop doesn't even finish before the part is deleted. Here's an example script:

for i =1,100 do
	script.Parent.Mesh.Scale = script.Parent.Mesh.Scale + Vector3.new(0.01,0.001,0.01)
	script.Parent.Transparency = script.Parent.Transparency + 0.07
	wait(0.000000000000000001)
end

I'd use something like that to scale a shockwave when a player jumps.

A friend of mine said that I should try using TweenService, and I did. It works on every part that doesn't need to be rotated. When I try to rotate a part with TweenService, it just launches into the air and then spins.

Here's an example of that: Link

Is there anyway to stop the lag, or maybe a better way to rotate parts?

Thanks for reading!

4 comments

0

Try using TweenService, as far as I know it skip execution steps, that means when your game lags it skips some of the movement but would be unnoticeable.

0

I did use TweenService. As I said, it messes up parts when they rotate. I showed an example in the link. Thanks for the comment

0

Is the example using the loop you have in the code block or tweenservice? Best way tor rotate parts is to manipulate their CFrames.

0

The example is using TweenService