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
 

How to convert number to percentage?

Previous Thread :: Next Thread 
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
03 Mar 2014 08:12 PM
First of all, I'm horrible at math.

I'm trying to convert a loop to a percentage, like here

for i = 1, #assets do
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id="..assets[i])
script.Parent.Text = (i/100) * 100 .."%"
wait(0.5)
end

I want it to output to script.Parent.Text the percentage to which it is out of 100

So it loads the assets, and shows it on the screen as the percentage done instead of the number of assets done

This just shows the number of assets done.
Report Abuse
jetlogan is not online. jetlogan
Joined: 05 May 2010
Total Posts: 1423
03 Mar 2014 08:16 PM
for i = 1, #assets do
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id="..assets[i])
script.Parent.Text = i / 2.."%"
wait(0.5)
end
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
03 Mar 2014 08:20 PM
@Jet
Outputs 1% instead of 100%
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Mar 2014 08:27 PM
Turn a decimal into a percent;

0.05 * 100 = 5%
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
03 Mar 2014 08:29 PM
Yeah but how can I make it so, that if it finishes all the items in the table "assets" it will be 100%
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Mar 2014 08:32 PM
depends, how many asserts are there?
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
03 Mar 2014 08:33 PM
2, but it will change a lot, is there a way to get a number of how many items are in the table?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Mar 2014 08:42 PM
table = {}

a=0
for I, v inpairs(table) do
a = a+1
end
print(a)


Wait...Did I do that right? I think I messed up the for loop...
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
03 Mar 2014 08:43 PM
..what
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
03 Mar 2014 08:43 PM
/\
missed a space
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
03 Mar 2014 08:48 PM
Sorry that threw me way off
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
03 Mar 2014 09:03 PM
I found a different way, but I still require a way for the script to count all the items in the table

Is there a way to do that?
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
03 Mar 2014 09:06 PM
Figured it out table.maxn (table id)
Report Abuse
slayer9365 is not online. slayer9365
Joined: 22 Oct 2007
Total Posts: 2312
03 Mar 2014 09:48 PM
you can simply do #assets. That will give you the number of elements in the table...
Report Abuse
Haschwalth is not online. Haschwalth
Joined: 30 Sep 2009
Total Posts: 24661
03 Mar 2014 09:49 PM
(i/#assets) * 100 .."%"
Report Abuse
coolsamoXD1234 is not online. coolsamoXD1234
Joined: 30 Sep 2012
Total Posts: 47
03 Mar 2014 09:50 PM
Ye...
print(#Table)
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