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?
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!