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

I do no understand these GUI's movement, halp?

Asked by 8 years ago

I think its kind of basic concept. You've seen it in most popular games on the front page, but how would I do it? I tryed doing it with TweenPosition or TweenSize but it never works out so here is the following code that doesn't conduct the way I wanted

1for i = 1, 2 do
2wait(.1)
3script.Parent.GradientDownwards:TweenPosition(UDim2.new(0, .025, 0))
4script.Parent.GradientUpwards:TweenPosition(UDim2.new(0, .025, 0)) 
5end

Sure it works, but I don't understand whats going on I change the numbers nothing happens decides the Vector3 thing at the end of the UDim2 thing. So can someone give me an understanding towards GUI movement or size?

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

Tweening a gui is just a way to make your gui slide or change size smooth and easily. They can either be changed by TweenPosition, TweenSize, or both with TweenSizeAndPosition

With tweening, you don't need to use a for loop, or a while true do loop. The Parameters that you put in basically sets up the loop for you.

Now TweenPosition needs 6 Parameters, the first argument is required. The Parameters are

01endPosition
02Type: UDim2
03Required
04 
05easingDirection
06Type: EasingDirection
07Defaults to: Enum.EasingDirection.Out
08 
09easingStyle
10Type: EasingStyle
11Defaults to: Enum.EasingStyle.Quad
12 
13time
14Type: float
15Defaults to: 1
View all 23 lines...

(from the wiki)

So for example, this would look like

1Gui:TweenPosition(UDim2.new(0, 14, 0, 14), "Out", "Quad", 1, false, nil)

From my personal use, TweenPosition is the one you will be using the most. But for everyone that is different.

TweenSize allows you to change the size of the gui. TweenSize has the same Parameters as TweenPosition

For example, it would look like

1Gui:TweenSize(UDim2.new(0, 14, 0, 14), "Out", "Quad", 1, false, nil)

Now TweenSizeAndPosition does both of them at the same time.

The only change in Parameters is that they require both endposition and end size

so it would look like

1Gui:TweenSizeAndPosition(UDim2.new(0, 15, 0, 15), UDim2.new(1, 0, 1, 0), "Out", "Quad", 1, false, nil)

Basically all. Here is a link to the wiki that I used (because im a scrub and forgot) link

this might be a little overboard. the fix to your script is

1script.Parent.GradientDownwards:TweenPosition(UDim2.new(0, .025, 0, 0)) --the rest will default, you might need to fix the values for the UDim2
2script.Parent.GradientUpwards:TweenPosition(UDim2.new(0, .025, 0, 0))   --the rest will default, you might need to fix the values for the UDim2
Ad

Answer this question