I want to make a “pulse” type Tween, which will constantly increase and decrease a TextBox
during the game, infinitely.
The problem is that if I put this tween inside a while true do
, the rest of the script will not proceed and the game will freeze.
I’ve already tried putting the tween inside a coroutine
but it didn’t work.
How can I make a tween play constantly in the game without interfering with anything?
Create a script inside the TextBox that runs separately
do like what he said but dont forget to use
repeat wait() until Tween.Completed
Consider using a sine function instead of tweens
Something like this
local counter: number = 0
local speed: number = 5
game:GetService'RunService'.RenderStepped:Connect(function(dt)
counter += dt * speed
textLabel.TextTransparency = (math.sin(counter) + 1) * .5
end)
Increase in size? You can do it without loops:
local tweenservice = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
-1,
true
)
tweenservice:Create(TextBox,tweeninfo,{Size = UDim2.new(0.1, 0,0.05, 0)}):Play()
If you meant position or anything else you can change the third argument of tweenservice.
As for coroutines you have to activate them with ()
at the end for them to work like this:
coroutine.wrap(function()
--your code
end)()
i know it is off topic but what does it mean
local exampleVariable: Number
the :
sign
Luau typechecking
Bad idea to repeatedly use wait()
, instead, you can use Tween.Completed:Wait()
https://developer.roblox.com/en-us/api-reference/datatype/TweenInfo
If you set the a TweenInfo
's ‘RepeatCount’ property to a negative value it’ll repeat indefinitely.