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

Image Fade Script To Fade In And Out Script Won't Work?

Asked by 2 years ago

I'm Trying To Create A Script Which Fades An Image Label In Over 3 Seconds And Then Holds For 14 Seconds And Then Fades Out For Another 3 Seconds. But When I Put The Script Into A Local Script Inside The Image, The Image Shows But Doesn't Fade In Nor Out

local tweenService = game:GetService("TweenService")

local timeToFade = 3
local object = script.Parent
local tweenInfo = TweenInfo.new(timeToFade)
local goal1 = {}

goal1.ImageTransparency = 0

wait(14)

local timeToFade = 3
local object = script.Parent
local goal2 = {}

goal2.ImageTransparency = 1

local tween = tweenService:Create(object, tweenInfo, goal2)
tween:Play()

1 answer

Log in to vote
0
Answered by 2 years ago

I believe you forgot to play the first tween/create it. If you played the first tween after creating it, it would fade in then wait 14 seconds before fading out. The final script would look like this:

local tweenService = game:GetService("TweenService")

local object = script.Parent
local timeToFade = 3
local tweenInfo = TweenInfo.new(timeToFade)
local goal1 = {}
goal1.ImageTransparency = 0
local tween1 = tweenService:Create(object,tweenInfo,goal1)
tween1:Play()

wait(14+timeToFade)

local timeToFade = 3
local object = script.Parent
local goal2 = {}

goal2.ImageTransparency = 1

local tween2 = tweenService:Create(object, tweenInfo, goal2)
tween2:Play()

Also notice that in the wait() I added timeToFade since the second that a tween is played the next function executes which is a wait() meaning if you played it then the wait() and tween would play at the same time meaning that the tween2 would start only 11 seconds after tween1 instead of the desired 14 seconds.

I really hope this helped enjoy! If this helped could you mark it as an answer, Thanks!

0
Thank You Very Much For The Help, I Found A Work Around And It Was Really Clunky So This Helps Lots!!! Sileonrbx 2 — 2y
0
I'm glad this could help! strangejmaster43 139 — 2y
Ad

Answer this question