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

UDim2 script error?

Asked by 8 years ago
--UDim2 script by bossay123

while true do
script.Parent.Parent.Frame:TweenPosition(UDim2.new(0,-1,0))
wait(2)
script.Parent.Parent.Frame:TweenPosition(UDim2.new(0,1,0))
print(work)-- work is highlighted red
end

Work is hilighted red, but in the output there are no errors.

0
Where is work defined? TheDeadlyPanther 2460 — 8y
0
i have to define work? I just want to print "work" bossay123 45 — 8y
0
Then you'd wanna do print("work"). Altough even if it weren't defined your script wouldn't error jakedies 315 — 8y

3 answers

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

Well It seems like all of you are clueless.

Firstly

UDim2.new() Takes four arguements . first is X Size , Next is X Offset , Then .. Y Size, and Lastly Y Offset . Which would look like this in a script

UDim2.new(0.1,0,0.2,0)

Secondly

The Method :TweenPosition Also Takes four Arguments. it takes UDim2 Position , Then Easing Direction , Then Easing Style , And Lastly Time

The Different Easing Directions are:

In

Out

InOut

The Different Easing Styles are:

Quad

Back

Linear

Elastic

Bounce

Sine

Quart

Quint

The Links

Easing Direction

Easing Style

Tweening In General

Example

local frame --Set it equal to the frame object
frame:TweenPosition(UDim2.new(0.,3,0,0.4,0),'In','Quad',5)

Lastly

Besides :TweenPosition() there is Also :TweenSize() which takes the same arguments as Tween Position but smoothly Changes the Size of the Gui Object.

0
Good answer. Includes lots of explanations and examples. TheHospitalDev 1134 — 8y
Ad
Log in to vote
0
Answered by
Vrakos 109
8 years ago

UDim2 has four values to be go inside of it. These are X Scale, X Offset, Y Scale and Y Offset

Also, work doesn't seem to be defined.

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

UDim2

UDim2 needs four values in it instead of three like Vector3. There are two types of values that go into UDim2. Scale and Offset. Now let me explain each of them.

Scale

Scale is more of a ratio based on the screen size of the device/Parent of the gui. The values go to 0-1, 0 is nothing on that axis while 1 fills the whole parent on the axis. Although this can lead to much stretching of images if you're not okay with that.

Offset

Offset is based on pixels. it does NOT size or position itself based on the screen. so if you put the value as say 50, its 50 more pixels along that axis.

Using these in UDim2 Now in UDim2 you must use all the four values, X Scale,X Offset,Y Scale, and Y Offset. I suggest only using Scale or Offset as if you use both it can get confusing. So unless you have a reason, don't.

Also work isnt defined.

Answer this question