How to make the tweenService, when finished do the rest of the script function?

well, I have a question about the tweenService, which is how I can make it so that when the tween finishes, it does the rest of the function, as well as the wait() or something like that: :TweenSize(UDime2.new(1, 0, 1, 0), nil, nil, 0.5):Wait()

tweenName.Completed:Wait()

also you have to use tweenservice:create instead of what you are trying to do

else you have to wait(.5) seconds (as per your wait time in the tween you provided) if you don’t go with using tweenservice:create however tweenservice:create is way better.

I don’t know if it’s possible with TweenSize but you could try it with a normal tween.

local TweenService = game:GetService(“TweenService”)
local frame = script.Parent
local Tween = TweenService:Create(frame,TweenInfo.new(0.5),{Size = UDim2.new(1,0,1,0)})
Tween:Play()
Tween.Completed:Wait()

You can also check out documentation on TweenService.

Actually, it is possible to detect when the Tween will complete if you do call TweenSize/TweenPosition/TweenSizeAndPositionAndWhatever

If you reference a local function & variable which would detect Tweens either Cancelling or Completing, you can check what to do with it:

local function DetectTween(Completed) --This is a bool
    if Completed then
        print("This tween has completed successfully")
    else
        print("This tween was interrupted by another Tween, or cancelled")
    end
end

local Tween = GuiObject:TweenSize(UDim2.new(1, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 1, false, DetectTween)

The 6 parameters are as followed in chronological order:

  • The UDim2 you want to Tween
  • The EasingDirection
  • The EasingStyle
  • The Duration of the Tween
  • Permission to Interrupt other Tweens?
  • A callback function (Or basically detecting the Tween’s Status)

https://developer.roblox.com/en-us/api-reference/function/GuiObject/TweenSize

1 Like