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 and Math

Previous Thread :: Next Thread 
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
30 Apr 2012 10:06 PM
I've never ever worked with UDim2 so I'm not sure if this is correct.

expbar = script.Parent.EXPBar.Size
template = script.Parent.EXPTemplate.Size
exp = script.Parent.EXP.Value -- an Int value for the current exp out of the max
-- blah blah, coding....
expbar = UDim2.new(math.ceil(template/exp*100), 0, 0.2, 0)

Would that last line work? I don't want to script my enemies to test it just yet.
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
30 Apr 2012 10:26 PM
You can't assign a property to a variable. Otherwise, it is correct.
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 06:40 AM
But the variable equals something that has a value.


But, I guess i could just make it longer and say

script.Parent.EXPBar.Size = UDim2(code, #,#)

Right?
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 04:15 PM
Bump
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
01 May 2012 04:34 PM
What you're looking for is `exp/MaxExp`. That will give you the Scale you need.
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 04:39 PM
It didnt work. :\ Heres the output:

Players.DeVinci.PlayerGui.Class Gui.Frame.Main.Class1.Frame:18: attempt to perform arithmetic on global 'template' (a userdata value)
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
01 May 2012 04:46 PM
Because template isn't what I said. Template is a completely unrelated value. You want the amount of exp they have divided by the maximum amount they can get. Or the amount of exp it takes to get to the next level.
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 04:51 PM
Ok, I used that method and got this output:

Players.DeVinci.PlayerGui.Class Gui.Frame.Main.Class1.Frame:18: attempt to call global 'UDim2' (a table value)
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 04:58 PM
And template IS a related value, because its the background of the EXP bar.

I want the end of the expbar to match the end of the template when the exp is capped.
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
01 May 2012 05:12 PM
IF the expbar is inside the template then it'll match perfectly. Also check to make sure you didn't reassign UDim2 anywhere in your script.
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 05:26 PM
Ok, So I put the EXP Bar in the template. Heres the script:

exp = script.Parent.Exp.Value
expm = script.Parent.ExpMax.Value
level = script.Parent.Level.Value
bar = script.Parent.EXPTemplate.EXPBar.Size
levelup = true

while true do
if exp == expm and levelup == true then
level = level +1
exp = 0
expm = expm * 2
elseif level == 10 then
levelup = false
exp = expm
end
script.Parent.EXPTemplate.Text = exp.. "/" ..expm
script.Parent.LevelText.Text = "Level: "..script.Parent.Level.Value
bar = UDim2(math.ceil(exp/expm), 0, 1, 0)
wait()
end
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 05:29 PM
Realized one problem:

bar = UDim2(math.ceil(exp/expm), 0, 1, 0)

But theres no output and the script won't work.
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 05:29 PM
bar = UDim2.new(math.ceil(exp/expm), 0, 1, 0) is what I meant
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
01 May 2012 05:53 PM
[ Content Deleted ]
Report Abuse
fluffykatz is not online. fluffykatz
Joined: 29 Feb 2012
Total Posts: 2
01 May 2012 06:08 PM
can you help me script? ive read a lot and still dont quite get how to make a plane
Report Abuse
fluffykatz is not online. fluffykatz
Joined: 29 Feb 2012
Total Posts: 2
01 May 2012 06:09 PM
or make blocks follow pepole or be deadly
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 06:14 PM
Dont interupt my thread. This is serious stuff. Post one yourself.

Ok, So how would I frix that issue?
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 07:02 PM
bump
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
01 May 2012 07:36 PM
Bump -_-
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
02 May 2012 03:22 PM
Uber Bump
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