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: Cannot math.floor over 1,000?

Previous Thread :: Next Thread 
StartDeveloping is not online. StartDeveloping
Joined: 16 Feb 2015
Total Posts: 740
12 Jul 2015 11:12 PM
This line:
script.Parent.Experience.Text = "EXP: " ..math.floor(ShowExperience).. " / " ..((Level.Value * 10) + 10)

Is a changed function. It shows the exp (ShowExperience is a variable of the experience but added with commas) and when you change it's experience to 999, it works and actually changes. If you go to 1,000 or more, it says this weird error code:
bad argument #1 to 'floor' (number expected, got string)

Is there something wrong with my comma adder?

function AddComma(Value, Type)
local Final, Calculate = Value
while (true) do
Final, Calculate = string.gsub(Final, "^(-?%d+)(%d%d%d)", "%1,%2")
if (Calculate == 0) then break end
end
if Type == "Health" then
ShowHealth = Final
elseif Type == "MaxHealth" then
ShowMaxHealth = Final
elseif Type == "Experience" then
ShowExperience = Final
end
return Final
end

My theory: When it reaches over 1,000, it actually makes the variable a string, causing it to get string and saying "number expected". If so, please help me.
Report Abuse
StartDeveloping is not online. StartDeveloping
Joined: 16 Feb 2015
Total Posts: 740
12 Jul 2015 11:16 PM
Update:
I tried tonumber(ShowExperience), I still get the same error
Same goes with level, but over 100 gets the error
Report Abuse
LegitimatlyMe is not online. LegitimatlyMe
Joined: 30 Oct 2013
Total Posts: 1108
13 Jul 2015 12:28 AM
once it reaches 1000, it gets one comma: 1,000; Roblox recognizes that as a string instead of a number.
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
13 Jul 2015 12:29 AM
ye m8, u g0tta use d ','s in ur gsub now
Report Abuse
WillieTehWierdo200 is not online. WillieTehWierdo200
Joined: 13 Aug 2008
Total Posts: 1147
13 Jul 2015 12:35 AM
I am trying to post code but for some reason Roblox blocks the post due to improper language. Let me see if I can PM it to you.
Report Abuse
TheCreationWorld is not online. TheCreationWorld
Joined: 02 Nov 2014
Total Posts: 568
13 Jul 2015 01:10 AM
tonumber?
Report Abuse
StartDeveloping is not online. StartDeveloping
Joined: 16 Feb 2015
Total Posts: 740
13 Jul 2015 01:29 AM
tonumber exists or am I wrong?
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
13 Jul 2015 01:47 AM
Lol.

Lua is kind to you and doesn't rage when you performed a mathematical operation in a string of numbers: it just converted the string of numbers to actual integers.

You're adding a comma, and suddenly Lua can't do that anymore.

Get your number and apply math.floor before adding commas, then just make that your XP, rather than math.floor'ing the string.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
13 Jul 2015 08:07 AM
math.floor(string.gsub(1000,"%d"))

Try that.
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
13 Jul 2015 08:09 AM
...

gtfo fishguy.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
13 Jul 2015 09:00 AM
Excuse me? Do I see you helping?
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
13 Jul 2015 09:28 AM
i dont see u helping lmao
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
13 Jul 2015 09:40 AM
Oh shut up. Atleast I didnt make a group on skype called "discussion about ways fishguy100 should kill himself"
Report Abuse
StartDeveloping is not online. StartDeveloping
Joined: 16 Feb 2015
Total Posts: 740
13 Jul 2015 11:57 AM
Thank you guys for the help, but I actually fixed it. THank y'all 4 da help ;D
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