Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Changing tween from repeating to looping?

Asked by 5 years ago
Edited 5 years ago

I have this code:

local tweenService = game:GetService("TweenService") local part = script.Parent

local tweeningInformation = TweenInfo.new(

100, -- Length Enum.EasingStyle.Linear, -- Easing style of the TweenInfo Enum.EasingDirection.Out, -- Easing direction of the TweenInfo 50, -- Number of times the tween will repeat
true, -- Should the tween repeat? 5 -- Delay between each tween
)

local partProperties = { Size = Vector3.new(4000,1800,4000);

}

local Tween = tweenService:Create(part,tweeningInformation,partProperties) Tween:Play()

Right now it repeats 50 times. How would I instead make it loop an infinite number of times/as many times as possible as long as the server is up?

0
local tweenInfo = TweenInfo.new(100, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true, 5) tuanorn 6 — 4y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

This should work

while true do
local tweenService = game:GetService("TweenService") local part = script.Parent

local tweeningInformation = TweenInfo.new(

100, Enum.EasingStyle.Linear, Enum.EasingDirection.Out,50, repeat
true, 5 
)

local partProperties = { Size = Vector3.new(4000,1800,4000);}

local Tween = tweenService:Create(part,tweeningInformation,partProperties) 
Tween:Play
tween.Completed:wait()
end
Ad
Log in to vote
0
Answered by
Nowaha 459 Moderation Voter
5 years ago

Here's a fixed version of the above answer.

The code has been moved into a while true do loop, which will mean that it will keep repeating as long as true is true, and true will always be true, so forever.

At the bottom we also added a Tween.Completed:Wait(); call, so that the loop will only repeat after the tween has ended.

while true do
    local tweenService = game:GetService("TweenService");
    local part = script.Parent;

    local tweeningInformation = TweenInfo.new(100, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 50, true, 5);

    local partProperties = { Size = Vector3.new(4000,1800,4000);}

    local Tween = tweenService:Create(part, tweeningInformation, partProperties) ;
    Tween:Play();
    Tween.Completed:Wait();
end;

Answer this question