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

Why is this script skipping a line that requires it to decrease a size of a gui?

Asked by 2 years ago

So when i made a tween for a bar to simply increase the size of X, i also added a line so when it reaches the end, it should go back to 0 size, but it doesn't

Here is the script:

local Event = game:GetService("ReplicatedStorage").ClientEvents:WaitForChild("AtomStartProgress")
local Tween_Service = game:GetService("TweenService")

local Fill_Time = 1

local Tween_Information = TweenInfo.new(Fill_Time,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0)

local Tween_Targerts = {

    Size = UDim2.new(0,250, 0,35),
    Position = UDim2.new(0.321, 0, 0.22, 0)
}

local Fill_Tween = Tween_Service:Create(script.Parent,Tween_Information,Tween_Targerts)

wait(0.4)

Event.Event:Connect(function()

    Fill_Tween:Play()

    wait()

    script.Parent.Size = UDim2.new(0,1, 0,35)

end)



1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

You didn't give time and did wait(). The tween is longer and so after it plays (without finishing) it goes to the next code and it does

 script.Parent.Size = UDim2.new(0,1, 0,35)

but the tween is still going so it changes the size (by the tween) and finishes the code.

So you can do wait() longer like wait(1.5)

Event.Event:Connect(function()

    Fill_Tween:Play()

    wait(1.5)

    script.Parent.Size = UDim2.new(0,1, 0,35)

end)
0
Basically, it didn't skip the line. As soon as the tween plays, it goes to the next line and did the last part but change by the tween again. AProgrammR 398 — 2y
Ad

Answer this question