Malformed pattern (missing '[')

  1. What do you want to achieve?
    I’m trying to make sure my string only contains numbers or decimals.

  2. What is the issue?
    I keep on getting this error “malformed pattern (missing ‘[’)”.

  3. What solutions have you tried so far?
    I have tried looking everywhere on the dev hub and have found people having similar’ish problems but none of their fixes worked for me.

I am terrible with string functions.

     btns.sizeY.Text = btns.sizeY.Text:gsub("%f", '')

Found this string method on the dev forum by the way because string methods are too hard for me.

They’re tricky haha. This might be what you want, it will replace any normal character from the string:

 btns.sizeY.Text = btns.sizeY.Text:gsub("%a+", '')

I don’t know if other symbols can be present in your strings though.

1 Like

Special characters can still be inputted, but I’ll just keep your version and implement a pcall or something like that which will notify the player when a error occurs.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.