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 » Scripters
Home Search
 

Re: How to index a variable in UDim2

Previous Thread :: Next Thread 
Dragoloy is not online. Dragoloy
Joined: 02 Nov 2012
Total Posts: 252
03 Oct 2015 10:20 PM
This is my third question in Scripters today. I appreciate the help I've received so far. Thanks!

How can I index a variable in UDim2? I'm trying to do this:

local UDim2 = 0.4

while wait() and UDim2 > 0.05 do
UDim2 = UDim2 - 0.01
textlabel.Position = UDim2.new(0.24,0,UDim2,0)
end

When I ran this, it didn't work. The output said, "attempt to index 'Udim2', a number value," or something along those lines.
Thanks in advance.

~Dragoloy, President of Drago Inc.~
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
03 Oct 2015 10:21 PM
Rename your UDim2 variable to something else like

local UDim2YScale = 0.4
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
03 Oct 2015 10:22 PM
Maybe use a different variable name.

local yScale= 0.4

while wait() and yScale> 0.05 do
yScale= yScale - 0.01
textlabel.Position = UDim2.new(0.24,0, yScale, 0)
end

Or just use a for loop:

for i = .4, .05, -.01 do
textlabel.Position = UDim2.new(0.24, 0, i, 0)
end

-The [Guy]
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
03 Oct 2015 10:23 PM
Forgot the wait()

for i = .4, .05, -.01 do
textlabel.Position = UDim2.new(0.24, 0, i, 0)
wait()
end

-The [Guy]
Report Abuse
Dragoloy is not online. Dragoloy
Joined: 02 Nov 2012
Total Posts: 252
03 Oct 2015 10:23 PM
Yeah, the problem was the variable name lol. Thanks!


~Dragoloy, President of Drago Inc.~
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
03 Oct 2015 10:23 PM
I still suggest you use the for loop :3

-The [Guy]
Report Abuse
Dragoloy is not online. Dragoloy
Joined: 02 Nov 2012
Total Posts: 252
03 Oct 2015 10:33 PM
Yeah, that for loop worked well. Thank you!


~Dragoloy, President of Drago Inc.~
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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