So I'm making a Light Placing plugin (I know, super original!) and when i click, I want a gui to appear asking you things like "How bright?". But, obviously, is someone typed letters in it, it would obviously error.
M39a9am3R is right.
--tonumber will turn a string into a number or return nil if the string is not a number tonumber("hello!")--nil tonumber("1244")-1244
Then to have the TextBox only use numbers, just do something like this.
textbox = script.Parent.TextBox --or something textbox.FocusLost:connect(function() if tonumber(textbox.Text) then --do stuff with textbox.Text being a number end end)
And if you wanted the players not be able to type letters, then do this.
textbox = script.Parent.TextBox --or something textbox.Changed:connect(function(prop) if prop == "Text" then if not tonumber(textbox.Text) then textbox.Text = textbox.Text:sub(1,#textbox.Text-1) --using sub to delete the last thing in the string --since this fires every single time they type something, it should delete letters instantly end end end)