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

GUI Tween stops moving occasionally?

Asked by 7 years ago
Edited 7 years ago

So, I have a local script in a gui image label that looks like this:


local fight = script.Parent while true do fight:TweenPosition(UDim2.new(0.5, -200,0.5, -80), "InOut") wait(1) fight:TweenPosition(UDim2.new(0.5, -200,0.5, -60), "InOut") wait(1) end

What it's supposed to do is to make the image bob up and down. It works fine, but occasionally, the image stops moving for a few seconds and starts to move again. Am I missing something in the script?

0
You don't have the argument "override" set, which is set to 'false' by default. This means that if, while it's moving, it is asked to tween to somewhere else, it will change its current task and move to the new place, if its set to true. RedneckBane 100 — 7y

1 answer

Log in to vote
3
Answered by
Newrown 307 Moderation Voter
7 years ago
Edited 7 years ago

The missing element which is causing the delay is that the tweening waits until it reaches the exact position, to be able to tween again.

TweenPosition() takes six parameters:

Parameter 1: End position as UDim2 2: Easing direction (which you have indicated as "InOut") 3: Easing style ("Quad", "Sine", "Elastic" etc.) 4: Time (The amount of time it takes to do the transition) 5: Override (Boolean value, if set to true = it has to reach its End position before it's
able to start another transition) 6: Callback function (Will return whether the tween will be able to start a transition)

To be able to fix this problem, you would want to set the Override value to true when you call TweenPosition() to true since you do not want the program to wait until the End Position is reached to execute another transition.

So the code will look something like this:

local fight = script.Parent

while true do 
    fight:TweenPosition(UDim2.new(0.5, -200,0.5, -80), "InOut", "Quad", 1.5, true)
    wait(1)
    fight:TweenPosition(UDim2.new(0.5, -200,0.5, -60), "InOut", "Quad", 1.5, true) 
    wait(1)
end

Hope this helped!

0
I must thank you for fixing my problem. I'll remember this for future uses. flufffybuns 89 — 7y
0
Happy to help :) Newrown 307 — 7y
Ad

Answer this question