-
What do you want to achieve? Keep it simple and clear!
So basically i have a code to tween any type of gui object with function in moduleScript. But i can’t make it wait until function finishes -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tryed using repeat until function return true but it not really work
Code to call function:
for i=1,length do
local skipped = TalkingLabel:GetAttribute("skipped")
if skipped == false then
TalkingLabel.Text = StoryMessages:RetrieveMessage("Beginning...", "Messages", i)
local check = ClientFunctions:AdjustTransparency(TalkingLabel, 0, 250)
repeat task.wait(0.1); print(check) until check == true
local reverseCheck = ClientFunctions:AdjustTransparency(TalkingLabel, 1, 250)
repeat task.wait(0.1); print(check) until reverseCheck == true
end
end
Tween Function code:
function ClientFunctions:AdjustTransparency(UI, targetTransparency, Time, requireBackground)
local currentTween
local backgroundTween
local UIStrokeTween
local UIType
local function ChangeTransparency(UIType)
local TimeInSeconds = Time/1000
local tweenInfo = TweenInfo.new(TimeInSeconds, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local UITransparencyProperty = string.format("%sTransparency", UIType)
if UIType == "Text" then
currentTween = TweenService:Create(UI, tweenInfo, {TextTransparency = targetTransparency})
elseif UIType == "Image" then
currentTween = TweenService:Create(UI, tweenInfo, {ImageTransparency = targetTransparency})
elseif UIType == "Background" then
currentTween = TweenService:Create(UI, tweenInfo, {BackgroundTransparency = targetTransparency})
end
if requireBackground then
backgroundTween = TweenService:Create(UI, tweenInfo, {BackgroundTransparency = targetTransparency})
if UI:FindFirstChild("UIStroke") then
UIStrokeTween = TweenService:Create(UI.UIStroke, tweenInfo, {Transparency = targetTransparency})
end
end
end
if UI:IsA("TextLabel") or UI:IsA("TextButton") then
UIType = "Text"
elseif UI:IsA("ImageLabel") or UI:IsA("ImageButton") then
UIType = "Image"
elseif UI:IsA("Frame") or UI:IsA("ScrollingFrame") then
UIType = "Background"
end
ChangeTransparency(UIType)
currentTween:Play()
if requireBackground then
backgroundTween:Play()
if UI:FindFirstChild("UIStroke") then
UIStrokeTween:Play()
end
end
currentTween.Completed:Connect(function()
print(1)
return true
end)
end