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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Variables in UDim2?

Previous Thread :: Next Thread 
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:23 PM
I have a series of equations set up in the script, and I need a specific value named 'sizB' as the second term in UDim2.new(0,0,0,0).
However, whn I input the name there, it sets it to 0, how do put the sizB part in the UDim2 set?
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
07 May 2013 09:31 PM
What is sizB equal too?

UDim2.new (0, sizB, 0, 0)

Something like this?
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:35 PM
Yes.
sizB = LvWildCURHP*sizA

sizA = 200/LvWildMAXHP

LvWildCURHP = script.Parent.Parent.Parent.Bar.HP_Meter.HPC_Value.Value

LvWildMAXHP = script.Parent.Parent.Parent.Bar.HP_Meter.HPM_Value.Value


Both CURHP and MAXHP are specific IntValues
Report Abuse
1GREENBOB123456 is not online. 1GREENBOB123456
Joined: 07 Nov 2010
Total Posts: 56
07 May 2013 09:37 PM
sizB must be after sizA because sizA isn't defined until after sizB is defined.
Report Abuse
1GREENBOB123456 is not online. 1GREENBOB123456
Joined: 07 Nov 2010
Total Posts: 56
07 May 2013 09:42 PM
and LvWILDMAXHP and the other variable must be before sizB
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:43 PM
Well, they were posted backwards...but they're in this order:

LvWildCURHP
LvWildMAXHP
sizA
sizB


This is the script without the references at the top;

while wait() do
script.Parent.Parent.Parent.Bar.HP_Meter.Size = UDim2.new(0, sizB, 0, 10)
end

LvWildCURHP.Changed:connect(function(check)
if LvWildCURHP > LvWildMAXHP then
wait()
LvWildCURHP = LvWildMAXHP
end
end)
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
07 May 2013 09:44 PM
If they are values, then you need to put "sizB.Value".
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:46 PM
So it should actually be;



LvWildCURHP = script.Parent.Parent.Parent.Bar.HP_Meter.HPC_Value.Value

LvWildMAXHP = script.Parent.Parent.Parent.Bar.HP_Meter.HPM_Value.Value

sizA = 200/LvWildMAXHP.Value

sizB = LvWildCURHP.Value*sizA.Value


Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:46 PM
And then;

script.Parent.Parent.Parent.Bar.HP_Meter.Size = UDim2.new(0, sizB.Value, 0, 10)
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:48 PM
Sorry, Ineeded to fix this, but it should look like such?

LvWildCURHP = script.Parent.Parent.Parent.Bar.HP_Meter.HPC_Value.Value
LvWildMAXHP = script.Parent.Parent.Parent.Bar.HP_Meter.HPM_Value.Value
sizA = 200/LvWildMAXHP
sizB = LvWildCURHP*sizA.Value



script.Parent.Parent.Parent.Bar.HP_Meter.Size = UDim2.new(0, sizB.Value, 0, 10)
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
07 May 2013 09:49 PM
Aside from un necasary parents. Yes. That looks good.
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:50 PM
What do you mean about the parents?
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
07 May 2013 09:52 PM
Actually, I am seeing problems. You're adding properties to Variables. You can't do that.
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:53 PM
I noticed it a second ago xD
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:55 PM
So what would it look like then? o.o
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
07 May 2013 09:55 PM
Post you're new Variables.
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
07 May 2013 09:55 PM
Can I have the entire script?
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:56 PM
The variables didn't change since doing anything would be trying to make the script find nil properties..

LvWildCURHP = script.Parent.Parent.Parent.Bar.HP_Meter.HPC_Value.Value
LvWildMAXHP = script.Parent.Parent.Parent.Bar.HP_Meter.HPM_Value.Value
sizA = (200/LvWildMAXHP)
sizB = (LvWildCURHP*sizA)
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 09:58 PM
This is the entire script:

LvWildCURHP = script.Parent.Parent.Parent.Bar.HP_Meter.HPC_Value.Value
LvWildMAXHP = script.Parent.Parent.Parent.Bar.HP_Meter.HPM_Value.Value
sizA = (200/LvWildMAXHP)
sizB = (LvWildCURHP*sizA)

while wait() do
script.Parent.Parent.Parent.Bar.HP_Meter.Size = UDim2.new(0, sizB, 0, 10)
end

LvWildCURHP.Changed:connect(function(check)
if LvWildCURHP > LvWildMAXHP then
wait()
LvWildCURHP = LvWildMAXHP
end
end)
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
07 May 2013 10:03 PM
Meter = script.Parent.Parent.Parent.Bar.HP_Meter
LvWildCURHP = Meter.HPC_Value
LvWildMAXHP = Meter.HPM_Value
sizA = (200/LvWildMAXHP.Value)
sizB = (LvWildCURHP.Value*sizA)

while wait() do
Meter.Size = UDim2.new(0, sizB, 0, 10)
end

LvWildCURHP.Changed:connect(function(check)
if LvWildCURHP.Value > LvWildMAXHP.Value then
wait()
LvWildCURHP.Value = LvWildMAXHP.Value
end
end)

--I editted it on my knowledge of your script. Not 100% sure if this is right, but I cleaned it up a bit. Gimmie an output if it doesn't work.
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 10:10 PM
There was no difference between when I ran miine, and this one.
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
07 May 2013 10:13 PM
Is that good?
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 10:14 PM
No, where the sizB is, the UDim2 is just being set to 0.
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
07 May 2013 10:46 PM
Bump.
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
07 May 2013 11:37 PM
What is sizB.Value?
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