generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: UDim2

Previous Thread :: Next Thread 
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
13 Mar 2013 05:48 PM
local Gui = script.Parent

if script.Parent.Parent.Parent == PlayerGui then

wait(1)

Gui.Position = UDim2.new(220, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(225, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(230, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(230, 0, 250, 0)

wait(0.1)
Gui.Position = UDim2.new(235, 0, 250, 0)

wait(0.1)
Gui.Position = UDim2.new(240, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(245, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(250, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(255, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(260, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(265, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(270, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(275, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(280, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(285, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(290, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(295, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(300, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(305, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(310, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(315, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(320, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(325, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(330, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(335, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(340, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(345, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(350, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(355, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(360, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(365, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(370, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(375, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(380, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(385, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(390, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(395, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(400, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(405, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(410, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(415, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(420, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(425, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(430, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(435, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(440, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(445, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(450, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(455, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(460, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(465, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(470, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(475, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(480, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(485, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(490, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(495, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(500, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(505, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(510, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(515, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(520, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(525, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(530, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(535, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(540, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(545, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(550, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(555, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(560, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(565, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(570, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(575, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(580, 0, 250, 0)

wait(0.1)


Gui.Position = UDim2.new(585, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(590, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(595, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(600, 0, 250, 0)

wait(0.1)


Gui.Position = UDim2.new(605, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(610, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(615, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(620, 0, 250, 0)

wait(0.1)


Gui.Position = UDim2.new(625, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(630, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(635, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(640, 0, 250, 0)

wait(0.1)


Gui.Position = UDim2.new(645, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(650, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(655, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(660, 0, 250, 0)

wait(0.1)


Gui.Position = UDim2.new(665, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(670, 0, 250, 0)

wait(0.1)

Gui.Position = UDim2.new(675, 0, 250, 0)

script.Parent.Parent:remove()

end

If the GUI's Parent is PlayerGui then the Frame of the gui moves to these positions.
No output.
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
13 Mar 2013 05:49 PM
Holy...

for loops and TweenPosition()
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
13 Mar 2013 05:53 PM
Assuming this is in StarterGui, the script won't run until it reaches the PlayerGui (which it does when the player re-spawns). So remove that if statement, and it's end, and then learn about TweenPosition.

http://wiki.roblox.com/index.php/TweenPosition_(Method)
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
13 Mar 2013 05:56 PM
I dislike TweenPosition its confusing.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
13 Mar 2013 05:59 PM
It's very simple to use and much easier than what you're doing. The wiki article explains it pretty well, but what is the confusing part?

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
13 Mar 2013 05:59 PM
Are you kidding me???

Gui:TweenPosition(UDim2.new(X,Y,X,Y))
Gui:TweenPosition(UDim2.new(X,Y,X,Y),"Out")

For a better animation
Gui:TweenPosition(UDim2.new(X,Y,X,Y),"Out","Bounce")
http://wiki.roblox.com/index.php/EasingStyle

to define the time that the tween will take:
Gui:TweenPosition(UDim2.new(X,Y,X,Y),"Out","Bounce",3)
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
13 Mar 2013 06:03 PM
local GUI = script.Parent

GUI:TweenPosition(UDim2.new(1, 0, 0, 0))
wait(1.5)
GUI:TweenPosition(UDim2.new(10, 0, 0, 0))

So this will move it smoothly to 10?

Will it go through 2,3,4,5,6,7,8,9?
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
13 Mar 2013 06:04 PM
Yes. And to control the time it takes, set the 4th argument. (The default is 1 second)
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
13 Mar 2013 06:04 PM
And also, I think you want just

GuiObject:TweenPosition(UDim2.new(10,0,0,0),_,_,1.5)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
13 Mar 2013 06:05 PM
For a standard tween, with no effects, just do:


    GUI:TweenPosition(UDim2.new(10, 0, 0, 0), "Out", "Linear", 1.5)

Note that the script will not yield the time you set.

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
ScriptsAndStuff is not online. ScriptsAndStuff
Joined: 21 Feb 2013
Total Posts: 264
13 Mar 2013 06:07 PM

function move(object,x,y,speed)

cx = object.Position.X.Offset
cy = object.Position.Y.Offset

dx = x-cx
dy = y-cy

dist = ((dx^2)+(dy^2))^.5

for i=1,dist do
cx = cx + (dx/dist)
cy = cy + (dy/dist)
object.Position = UDim2.new(0,cx,0,cy)
wait(1/speed)
end
end


function moveSteps(object,x,y,steps)

cx = object.Position.X.Offset
cy = object.Position.Y.Offset

dx = x-cx
dy = y-cy
for i=1,steps do
cx = cx + (dx/steps)
cy = cy + (dy/steps)
object.Position = UDim2.new(0,cx,0,cy)
wait()
end
end

ROFL UMAD?
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
13 Mar 2013 06:08 PM
.....
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
13 Mar 2013 06:12 PM
So this

local Gui = script.Parent

Gui:TweenPosition(UDim2.new(0,220,0,250))

Gui:TweenPosition(UDim2.new(0,675,0,250),"Out",1.5)

Will move from 220 to 675 smoothly in 1.5 seconds?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
13 Mar 2013 06:13 PM
You forgot the third argument. Set it to "Linear".

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
13 Mar 2013 06:13 PM
it would move it to 220 first and then 675...
and you forgot an argument.

Gui:TweenPosition(UDim2.new(0,220,0,250))

Gui:TweenPosition(UDim2.new(0,675,0,250),"Out","Linear",1.5)
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
13 Mar 2013 06:14 PM
Will linear make the Frame go through 225,226 and so on till it gets to 675?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
13 Mar 2013 06:15 PM
Yes, they all do, just the others will make the speed a little more spontaneous, Linear is the one that will make speed uniform.

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
13 Mar 2013 06:18 PM
Okay thank you guys for giving me a better understanding in TweenPosition

Now back to the script

local Gui = script.Parent

if Gui.Parent == PlayerGui then

Gui:TweenPosition(UDim2.new(0,220,0,250))

Gui:TweenPosition(UDim2.new(0,675,0,250),"Out","Linear",5)

wait(.5)

Gui.Parent:remove()

end

Will this script check to see if the Gui's parent is the PlayerGui then move the frame?
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
13 Mar 2013 06:20 PM
I have a working script that clones the gui into the PlayerGui(The gui that moves is located in lighting.)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
13 Mar 2013 06:35 PM
It should be:


    if Gui.Parent == "StarterGui" then

If you want it to constantly check, you can do:

    repeat Wait( ) until Gui.Parent == "StarterGui"

¤ ¤ † K M <( •д• )> X D † ¤ ¤

Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
13 Mar 2013 06:51 PM
But the startergui is not what the player is seeing the startergui puts the gui into the playergui.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
13 Mar 2013 06:53 PM
Sorry, I meant to type "PlayerGui".

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
13 Mar 2013 07:01 PM
Hey i just tested it, it does not move but there is no output.
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
14 Mar 2013 06:20 PM
Remove the first TweenPosition method you have in your code, it serves no purpose other then to hold up the one below it.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image