|
| 26 Apr 2014 07:29 PM |
function CheckForNums(Box) if Box:IsA("TextBox") then TT = {} for i=1, #Box.Text do TT[#TT] = Box.Text end Box.Text = "" for _,v in pairs(TT) do if tonumber(v) ~= nil then Box.Text = Box.Text..v end end end end
while wait() do CheckForNums(script.Parent) end
Well, this will make that you can only type numbers on the textbox. The only problem is that when you already typed a number, and then type a letter, the entire number gets deleted. |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2014 07:45 PM |
Box.FocusLost:connect(function() Box.Text = string.gsub(Box.Text, "[^%d,]+", "") end)
|
|
|
| Report Abuse |
|
|
Devoi
|
  |
| Joined: 09 Jun 2013 |
| Total Posts: 5387 |
|
|
| 26 Apr 2014 08:05 PM |
Box.Changed:connect(function() Box.Text = string.gsub(Box.Text, "[^%d,]+", "") end)
y u do dis echo |
|
|
| Report Abuse |
|
|
xSIXx
|
  |
| Joined: 06 Aug 2010 |
| Total Posts: 9202 |
|
|
| 26 Apr 2014 08:19 PM |
dear op
lrn2string functions
|
|
|
| Report Abuse |
|
|
oseday
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 1308 |
|
|
| 27 Apr 2014 04:44 AM |
| Why not just use type() and tonumber()? |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2014 06:34 AM |
@dev:
You're right -- I should have used :changed() instead for two reasons:
1) If something other than the player modifies the text 2) It will prevent non-digits from being entered into the TextBox completely
(explanation for OP's sake)
@ose:
"use type()" A TextBox's text will always be a string -- there's no need for type().
"and tonumber()?" print(tonumber("123abc4")) >nil |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2014 10:05 AM |
^ And that is why I prefer C.
EOS db 0x00 ;End of String Marker |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2014 11:50 AM |
| lol people, thanks for helping me fix my script. I wasn't actually asking to you guys to fix my script, i was only divulging my "Achievement", if i was asking you guys to fix my script, i would've put this forum in Scripting helpers forum, but still, thanks. |
|
|
| Report Abuse |
|
|