If it is because something else in your game uses that letter, you can use ContextActionService or the GameProcessedEvent passed when using UserInputService’s events (to prevent the action in your game from running when the player is chatting)
Using ContextActionService:BindActionAtPriority(), you can bind an action to a keybind, and other actions using that keybind, with a lower priority, will be overwritten/disabled
Otherwise, you can code that behaviour if you fork the LegacyChat, in the ChatBar Module, on line 188 and down
The chat seems to detect inputs from Textbox.Changed. You can probably check the last character of Textbox.Text, and remove it if it is one of the letters you want to block. Or you could do a string.gsub on Textbox.Text as a whole, I doubt performance would be a concern
I highly doubt this is possible with TextChatService. You probably are able to remove letters from messages, but not prevent them from being typed
im making kinda a keyboard simulator thing where u need to unlock keys and you cant type a certain letter until you unlock it. it shouldnt be necessary that, i can do it like that: player chats, adn then i delete characters after he types, but thats not interesting. so i wanted to find out how do to it the other way
self.TextBoxConnections.TextBoxChanged = TextBox.Changed:connect(function(prop)
if prop == "AbsoluteSize" then
self:CalculateSize()
return
end
if prop ~= "Text" then
return
end
local DisallowedCharacters = {"a","b","c"} -- Get this from your other code :P
local StringLenght = #TextBox.Text
if table.find(DisallowedCharacters,string.sub(TextBox.Text, StringLenght, StringLenght)) then
TextBox.Text = string.sub(TextBox.Text, 1 , StringLenght -1)
return -- This will trigger TextBox.Changed, so return
end
self:CalculateSize()
if utf8.len(utf8.nfcnormalize(TextBox.Text)) > ChatSettings.MaximumMessageLength then
TextBox.Text = self.PreviousText
else
self.PreviousText = TextBox.Text
end
if not self.InCustomState then
local customState = self.CommandProcessor:ProcessInProgressChatMessage(TextBox.Text, self.ChatWindow, self)
if customState then
self.InCustomState = true
self.CustomState = customState
end
else
self.CustomState:TextUpdated()
end
end)
The code can look something like this, it only works with single character strings, but knowing your use case, this is probably fine