Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Changing tween from repeating to looping?

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?

1 comment

0

local tweenInfo = TweenInfo.new(100, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true, 5)

2 answers

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

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;

This discussion is preserved as it was. New answers, comments, and votes are closed.