#number only textbox

1 messages · Page 1 of 1 (latest)

vocal glade
#

i want to make a textbox that you can only type numbers into. if a nonnumber character is typed it either does not validate it or immediately delets it (preferebly the first one) I checked all over the internet and couldnt find anyhting on it

steel igloo
#
local tb = --path
tb.Changed:Connect(function(property)
  if property ~= "Text" then return end
  if tb.Text:match("^[0-9]+$") then return end
  tb.Text = tb.Text:sub(2)
  -- if the last one tb.Text = tb.Text:sub(1, -2)
end)
strong citrus
#
local textBox = -- Path

textBox:GetPropertyChangedSignal("Text"):Connect(function()
    textBox.Text = textBox.Text:gsub('%D+', '');
end)```
#

Always use :GetPropertyChangedSignal() over .Changed if possible