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

Is there a variable that is infinite?

So I want to repeat a Tweened part animation infinitely, I'm fairly new to scripting and I'm currently using for i = 1,1 do. However, this makes the part go back to it's original location. I just want to know if there is a variable to repeat this Tween so it never ends.


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

local tweeningInformation = TweenInfo.new(
	
2, -- Length
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
10, -- Number of times the tween will repeat
false, -- Should the tween repeat?
2 -- delay	
)

local partProperties = {
	Position = Vector3.new(-21.6,-21.4,-46)
}
local Tween = tweenService:Create(part, tweeningInformation, partProperties)
for i = 1,1 do
	Tween:Play()
end

2 comments

0

math.huge

0

at line 15, Use CFrame instead.

2 answers

try a while loop (i.e while wait() do)

2 comments

0

That doesn't work for me because the "while" gets a red underline

0

Tweens can loop infinitely without a loop required (i'm pretty sure). There's a float named "time" which tells the tween to repeat "time".Value. Change that float value to math.huge. Something to make the number infinite. The float is in the fourth arguement. Ye, you wrote it down as 10 times to repeat.

--[[ Tweens can loop infinitely without a loop required (i'm pretty sure). There's a float named "time" which tells the tween to repeat "time".Value. Change that float value to math.huge. Something to make the number infinite. The float is in the fourth arguement. Ye, you wrote it down as 10 times to repeat. ]]

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

local tweeningInformation = TweenInfo.new(

2, -- Length
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
math.huge, -- Number of times the tween will repeat
false, -- Should the tween repeat?
2 -- delay  
)

local partProperties = {
    Position = Vector3.new(-21.6,-21.4,-46)
}
local Tween = tweenService:Create(part, tweeningInformation, partProperties)

    Tween:Play() ---- to cancel tween, use Tween:Cancel()
 

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