Where would I interpret the ImageTransparency in this code so that it will Tween Fade the ImageLabel
-- Tween Control
local function ApplyTweenFade(Frame, Info : TweenInfo, Amount : number)
local Target= {}
if (Frame:IsA("GuiObject")) then
Target.BackgroundTransparency = Amount
elseif (Frame:IsA("UIStroke")) then
Target.Transparency = Amount
else
return
end
TweenService:Create(Frame, Info, Target):Play()
end
-- Gui
local StaminaGui = script.Parent
local Holder = StaminaGui:WaitForChild("Holder")
local Bar = Holder:WaitForChild("Bar")
local Label = Holder:WaitForChild("StaminaLabel")
local UIStroke = Holder:WaitForChild("UIStroke")
local UIStrokeTransparency = UIStroke.Transparency
local BackgroundTransparency = Bar.BackgroundTransparency
local ImageTransparency = Label.ImageTransparency
Holder.Visible = false -- Start hidden
this is the full Tween Fade for (AppyTweenFade) and (TweenFade)
-- Tween Control
local function ApplyTweenFade(Frame, Info : TweenInfo, Amount : number)
local Target= {}
if (Frame:IsA("GuiObject")) then
Target.BackgroundTransparency = Amount
elseif (Frame:IsA("UIStroke")) then
Target.Transparency = Amount
else
return
end
TweenService:Create(Frame, Info, Target):Play()
end
local function TweenFade(Frame, Amount : number)
local Info = TweenInfo.new (FadeTime)
ApplyTweenFade(Frame, Info, Amount)
for k, v in pairs(Frame:GetDescendants()) do
if (v:IsA("GuiObject")) then
ApplyTweenFade(Frame, Info, Amount)
end
end
end
local function HideStaminaBar()
TweenFade(Bar, 1)
TweenFade(UIStroke, 1)
TweenFade(Holder, 1)
TweenFade(Label, 1)
_stambarIsHidden = true
end
local function ShowStaminaBar()
TweenFade(Bar, 0.8)
TweenFade(UIStroke, 0.8)
TweenFade(Holder, 0.5)
TweenFade(Label, 0.5)
_stambarIsHidden = false
end
You could insert an if statement before the GuiObject class to check if the object is an ImageLabel first.
This is because the ImageLabel object is part of the GuiObject class.
local function ApplyTweenFade(Frame, Info : TweenInfo, Amount : number)
local Target= {}
if (Frame:IsA("ImageLabel")) then
Target.ImageTransparency = Amount
elseif (Frame:IsA("UIStroke")) then
Target.Transparency = Amount
elseif (Frame:IsA("GuiObject")) then
Target.BackgroundTransparency = Amount
else
return
end
TweenService:Create(Frame, Info, Target):Play()
end