Make player only type numbers

So let’s say you have a text box and you want the player only to be able to write numbers, no spaces, no letters, and who knows what else. Any help is appreciated!

1 Like
script.Parent.FocusLost:Connect(function()
if not tonumber(script.Parent.Text) ~= nil then
script.Parent.Text = ""
end
end)

Also,do not ask people to write entire systems for you.

Make this a localscript and put this inside the textbox

this would cause an error, also he didnt ask for a code, he asked for a hint or sth to point him in the right direction

sj to number and string pattern

I don’t think your getting what I’m trying to say. I just want it so you can only type numbers in that textbox. Not check if its only a number.

1 Like

You can use a string pattern to achieve this:

local TextBox = script.Parent --TextBox path

TextBox:GetPropertyChangedSignal("Text"):Connect(function()
	TextBox.Text = TextBox.Text:gsub("%D", "")
end)
1 Like