LuaCoold
(Cool)
#1
I’m currently trying to make a textbox only allow 1 word, and no more than that.
My current script:
Text:GetPropertyChangedSignal('Text'):Connect(function()
Text.Text = Text.Text:gsub('%p+', '');
Text.Text = Text.Text:gsub('%d+', '');
local tbl = string.split(Text.Text:gsub("%p", ""), " ")
if tbl[2] then
Text.Text:sub(1, #Text.Text - 1)
end
end)
I still don’t understand why it isn’t working, I tried searching some things up about patterns and strings and couldn’t find much.
This is wayyy over complicated if you are just trying to remove a space from the text, you can just do:
Text.Text = Text.Text:gsub(" ", "")
Also, as for why it doesn’t work:
You have to set Text.Text = Text.Text:sub(1, #Text.Text-1)
1 Like
Forummer
(Forummer)
#3
Text:GetPropertyChangedSignal("Text"):Connect(function()
Text.Text = Text.Text:gsub("%A", "") --Remove all non-alphabetic characters.
end)
2 Likes
ayoub50
(Ayoub)
#4
Text:GetPropertyChangedSignal("Text"):Connect(function()
local Length = string.len(Text.Text)
if Length > 1 then
Text.Text = ""
end
end)
LuaCoold
(Cool)
#5
Thanks for your help! I overthinked it alot.
Oh, and thanks for helping me shorten it
@Forummer !
1 Like