It's suppose to make a test equal to nothing if a player inserts letters etc.
while true do if script.Parent.Text == 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 0 or " " then else script.Parent.Text = " " end end
https://gyazo.com/90eef064a84956a9a0b97db79e700023
local textbox = script.Parent local function onFocusLost (enterpressed) if enterpressed then -- checks if the user has entered a number if textbox.Text == "1" or textbox.Text == "2" or textbox.Text == "3" or textbox.Text == "4" or textbox.Text == "5" or textbox.Text == "6" or textbox.Text == "7" or textbox.Text == "8" or textbox.Text == "9" then print("Player entered a valid number") else print("Player did not enter a valid number") end end end textbox.FocusLost:Connect(onFocusLost) -- this event let's the function run when the client loses their focus of the TextBox.
So, i made the numbers strings, because the text of a textbox is always a string.
and i added the FocusLost event so that it would only run when the client has entered text in the textbox.
So what you want to do is use tonumber on the text box's text if it does not return nil that means the text box contains numbers but if it does return nil that means the text box contains another character which is not a number.
Another thing to note instead of using a while loop is use :GetPropertyChangedSignal on the text box's text which would fire this function every time the text changes.
function NumberValidation () if tonumber(script.Parent.Text) ~= nil then return else script.Parent.Text = "" end end script.Parent:GetPropertyChangedSignal("Text"):Connect(NumberValidation)