Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to cancel a tween resizing a GUI?

Hi there. When the tween activates, it does not stop until it is completed. How would I go as to stop the tween, while it is running? Thanks!

local function executeAfter(complete)
					replicatedstorge:WaitForChild("Mining"):FireServer(cursorObject,damage)
	progress.Size = UDim2.new(0,0,1,0)
	hit = false
end


local tween2 = progress:TweenSize(
	UDim2.new(1,0,1,0),
	Enum.EasingDirection.Out,
	Enum.EasingStyle.Linear,
	2,
	false,
	executeAfter
)

2 comments

0

Do you mean to reset the tween or just completely stop it where it is?

0

To reset it. Hmm, I should have worded it as such. Sorry about that.

1 answer

✓ Accepted answer

TweenSize has the following properties: {size, direction, style, time, override, callback}

If you want the Tween to be reset, One Option is to use another tween to cancel it out. To do this, you first need to make sure its "override" is set to false (which you already have here), which means it cannot stop another tween that is already occurring.

Next, you need another connection / event to tween the same object "progress", except this time using its initial UDim2 Size.

For Example

local tween3 = progress:TweenSize(UDim2.new(0, 0, 1, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, 2, true, nil)

The above line assumes that "progress" has an initial size of (0, 0, 1, 0), where we reverse the Enum.EasingDirection, and change the "override" to true, meaning that this tween can override other tweens.

2 comments

0

Hey. Thanks for the help. I put the new code into the mouse.button1up function, and it sort of worked. However, when I let go, it wouldnt mine again. So, all I did was I used a boolean variable to check whether or not the person is mining. Thanks again!

0

No problem, it probably wouldnt let you mine because the other tween was not complete at the time, you can try making it have a shorter time to function

This discussion is preserved as it was. New answers, comments, and votes are closed.