|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 13 Jul 2015 01:29 AM |
| tonumber exists or am I wrong? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 13 Jul 2015 08:07 AM |
math.floor(string.gsub(1000,"%d"))
Try that. |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Jul 2015 09:00 AM |
| Excuse me? Do I see you helping? |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|