Hello, I’m trying make string pattern which will allow write only numbers in textBox. But my filter “%d%d%d%d%d%d” just erase EVERYTHING: numbers, symbols, letters. Can someone help me?
BrushConnections[#BrushConnections + 1] = TextInput:GetPropertyChangedSignal("Text"):Connect(function()
if TextInput:IsFocused() == true then
print("Text was: " .. TextInput.Text)
print("Now text is: " .. tostring(string.match(TextInput.Text, "%d%d%d%d%d%d")))
TextInput.Text = if (string.match(TextInput.Text, "%d%d%d%d%d%d")) ~= nil then string.match(TextInput.Text, "%d%d%d%d%d%d") else ""
end
end)
--Input: 1
--Output: nil
--Should: 1
--Input: g
--Output: nil
--Should: nil
Also, there’s no any other functions which will erase string.