TweenService or a for loop

I currently have a part that grows in size as long as the player has their mouse button held down/clicked.

I am currently using a for loop that incrementally adds 0.1 to the size.
So, something like this:

for i = 1,1000 do --the max size is 1000*0.1, hence the end value 1000

	if mouseButton1Down == false then
		break
	end
    size = size + 0.1

wait()

end

(I know that the code above is not ideal, but you get the picture…)

However, instead of adding the size property, would it be better to use tweenservice?
My idea with tweenService would be:
Have an animation that grows to the max value, but when the mouse button is released we do animation:Cancel()

I think using tweenservice might be the best solution.
Your ideas?

1 Like

Yes tweenservice will be better in this situation. You can cancel the tween if it is no longer being pressed (by using a runservice and checking). Be sure to do this on the client though!!

3 Likes

Tween service is less laggy, more options(stop,play,pause) whenever, better results overall.

2 Likes