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: How exactly would I do this?

Previous Thread :: Next Thread 
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
20 Jun 2013 09:06 AM
I know this requires some math, and I haven't learned complex math yet

So, let's say I have an xp bar(preferably a GUI)

I do a battle, and after, I get xp

The bar fills based on the xp I received.

How do I make a GUI fill up the bar based on a certain amount?
Report Abuse
Hergest is not online. Hergest
Joined: 17 May 2011
Total Posts: 309
20 Jun 2013 09:10 AM
Maybe like a ton of GUI's with green bars. And you make a script like.

if exp = > 1 then
game.Workspace.StarterGui.Exp.Exp2.Visible
end
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
20 Jun 2013 09:15 AM
Well, maybe something like this

So, let's say I need 150

I get 50 xp.

So, 50 will be one-third of the bar.

So, if the gui's total length is , let's say, 1 on the scale, then I could create a bar that fills up .33333, which is one-third of one.

Would this perhaps work?
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
20 Jun 2013 09:18 AM
@Herg,
Oh lord... No...

---

@OP,

If you created a frame which you used as the 'bar backing', and then put a frame inside that, you could use the XScale part of UDim2.new(). Since 'Scale' is a 'percentage' of the parent object's size, you could do this...

script.Parent.Size = UDim2.new(CurrentXP/XPOfNextLevel,0, 1, 0)

E.g.
script.Parent.Size = UDim2.new(100/300, 0, 1, 0) -- It would make the bar 1/3 full.

--

Bleh.Bleh.Changed:connect(function()
CurrentXP = Bleh.Bleh.CurrentXP
XPOfNextLevel = Bleh.Bleh.NextXPLevel
script.Parent.Size = UDim2.new(CurrentXP.Value/XPOfNextLevel.Value,0, 1, 0)
end)

For example ^^^

Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
20 Jun 2013 09:19 AM
The first gui that fills it up would be gui1.

So again, let's say, next battle I get 50 again.

So, it would be one-third of the bar again.

So, I could take the x-position of gui1, then add one-third(since I got that from my first battle), then, that would be where gui2 starts on the x grid. gui2, would then increase by one-third.
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
20 Jun 2013 09:31 AM
Wait, I can just use one gui

SO if the current one's size is {50/150, 0, .1, 1}

We can name this "previous"

Let's say next battle i get 70

The gui adds 70/150 to the 50/150

This will be named "current"

blah.blah.blah.blah..Size = UDim2.new(previous.Size.XScale + current.XScale, 0, .1, 0)

But then, how do I change the current to the previous after the next battle?

This is where I ran into a bump
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
20 Jun 2013 09:37 AM
I JUST THOUGHT OF SOMETHING

I can use the changed

So, there can be an intvalue in workspace, name "totalxp"

if this is changed, so is the XP gui

with every battle, the int will add a number to it

Every battle can have an xp variable named "xp"

so after every battle

totalxp.Value = totalxp.Value + xp.Value

xpneeded = 150

totalxp.Changed:connect(function(change)

xpgui.Size = UDim2.new(totalxp/xpneeded, 0, .1, 0)
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