Loop Tweening Help

So I feel like this is a small thing, but I looked in the developer hub and I couldn’t find much. At first I was kinda lost, and then I figured somethings out. Anyway what do I set the value to to loop it? (God my grammar here sucks)

Here is the code.

What is the value to set the callback variable to true?
(i feel so stupid :angst:)

1 Like

iirc you cannot loop TweenPosition and TweenSize. Consider using TweenService since it has a repeatcount parameter. Setting it to -1 will loop your tween infinitely.

1 Like

That’s not what the callback argument is for. The function will run the callback function once the tween has finished running.

It’s a bit unclear what you’re asking, by the way. Are you asking how to loop it or something relating to the callback? If you’re asking how to loop it, you might want to look into TweenService, a much more powerful service than the TweenPosition and TweenSize functions.

edit: got ninja’d


Sorry, I know about TweenService, but I thought it would be easier to do it this way.

1 Like

TweenPosition is definitely easier to use, but it’s unfortunately a lot less capable than TweenService as well.


You could actually use that callback to re-start the tween, in an infinite loop - or until some condition tells it to stop:

local stopPlayingTween = false
local originalStartPosition = image.Position

local function PlayTweenAnimation(playbackStatus)
  -- Verify the 'continue-or-stop condition' allows us to continue
  if not stopPlayingTween then

    if nil == playbackStatus or playbackStatus == Enum.TweenStatus.Completed then
      -- Before starting tween, set image's position back to the original position
      image.Position = originalStartPosition

        PlayTweenAnimation -- When tween finishes, then call this function
                           -- "Let's do the twist^h^h^h^h^h tween again"

-- To initiate the continuous tween animation, call function without any argument

-- And to avoid the "tween callback loop" continues forever,
-- then set the 'stop condition',  possibly after some time has passed,
-- or when player does something.
stopPlayingTween = true