Tween.Completed problem

I have to use Tweens in my project and detect when they finish to start the new leg (new tween). This should work normally, but I noticed that I have stack overflow due to function that makes tween is repeating over and over.

The problem is that I call it only 2 times, one to initiate test, second when previous Tween is finished. For 2nd call I use option of Tween.Completed event, but it’s just calling even before the tween was started.

Tween = TweenService:Create(instance,param,reach)
TweenEvent = Tween.Completed:Connect(functiontoserve)
--Tween:Play()

The fact that tween calling function is in comment… makes this so strange. Is it possible that Completed event fire even before tween starts?

You are using the same variable

Correction, I had to shorter my code, I use different values for event and tween.

Try this:

Tween = TweenService:Create(instance,param,reach)
TweenEvent = train.cur_tween.Completed:Connect(functiontoserve)
--TweenEvent:Play()

This is exactly what I do in my code.

Do you mean your .Completed event will fire before the tween starts?

If that’s the case:

  Tween = TweenService:Create(instance,param,reach)
  Tween:Play()
  TweenEvent = Tween.Completed:Connect(functiontoserve)