Hello! I’m trying to tween an ImageLabel, that is basically a text with a custom font, because roblox fonts sucks. But there’s one problem, the images did not tween the transparency smoothly like it would do with a TextLabel or Frame. I think that’s because the images aren’t loaded yet, but i’m not sure, because they are visible all the time.
Btw here’s the code:
local note = script.Parent.Note
local TweenService = game:GetService('TweenService')
TweenService:Create(
note,
TweenInfo.new(2),
{ImageTransparency = 1}
):Play()
local TweenService = game:GetService("TweenService")
local note = script.Parent:WaitForChild("Note")
local info = TweenInfo.new(2)
local tween = TweenService:Create(note, info, {ImageTransparency = 1})
tween:Play()
repeat
note.ImageTransparency += number
wait(number)
until note.ImageTransparency >= 1
vs
local tween = TweenService:Create(note, info, {ImageTransparency = 1)
tween:Play()
Not only does it use fewer lines of code and is easier to manage, it is also better practice to use TweenService when animating the properties of an Instance. There are also more possibilities when using tweens rather than loops, for instance the ability to utilize EasingDirection and EasingStyle. And another thing to note, OP wants this tween to last 2 seconds:
So, to figure out how to make the animation last 2 seconds in a loop, you would have to figure out how to increment that property and how to time the loop iterations to meet that goal while still maintaining the smoothness of the animation. That’s something TweenService does for you.