Roblox auto-correction*

Hello, I have a question.

How would i make it so if someone says “hello” it would automatically be send as “Hello.” instead.
Sort-of autocorrection but like, not entirely. I have no idea how i should do this but- Maybe one of ya do!

So basically every sentence should start with a capital letter and end with a “.”
Thank!

4 Likes
local function AutoCorrect(s: string)
	local newString = string.sub(s, 1, 1):upper() .. string.sub(s, 2) .. "."
	return newString
end

print(AutoCorrect("hello"))  --> Hello.
2 Likes

For the correction itself, you could probably just do something like

message:gsub("^%l",function(a) return a:upper() end):gsub("[^%.]$",function(a) return a.."." end)

As for automatically doing this, I would personally edit the chat module itself

So here’s some steps as to how you can do this
I apologize for the vagueness but I’m away from my computer atm

  1. Run your game, and find the chat service in the explorer which should be full of robloxs chat code
  2. copy the client modules folder, stop the play test, and paste the entire modules folder into the chat service in edit mode so it saves
  3. find the modulescript in the folder which has a name something like “defaultmessage” or “normalmessage”, and open it up
  4. search for .Text, this should be where the text labels text is set to the contents of the players message
  5. edit this line so that instead of just adding in the message, it adds in the gsub stuff

If you need help with any of these steps just show a screenshot or snippet of what you need help with and I should be able to help

4 Likes

Yeah im confused, could you explain where exaclty i need to place it?

image

Replace messageObject.Message with the gsub stuff, adding messageObject.Message as the parameter

image
You mean here?
Replace the entirely of messageObject.Message with
message:gsub("^%l",function(a) return a:upper() end):gsub("[^%.]$",function(a) return a…"." end)?

(Sorry if i sound stupid lmfao, I’m just don’t really understand the chatService

You would do like:

BaseMessage.Text = string.rep(blah blah blah...) .. BaseMessage.Message:gsub("^%l",function(a) return a:upper() end):gsub("[^%.]$",function(a) return a…"." end)

Sorry for being unclear

Uhh,
image

Remove one of the dots after the a, so it is just

return a.."." end

image

	local function UpdateTextFunction(messageObject)
		if messageData.IsFiltered then
			BaseMessage.Text = string.rep(" ", numNeededSpaces) .. BaseMessage.Message:gsub("^%l",function(a) return a:upper() end):gsub("[^%.]$",function(a) return a.."." end)
		else
			local messageLength = messageObject.MessageLengthUtf8 or messageObject.MessageLength
			BaseMessage.Text = string.rep(" ", numNeededSpaces) .. string.rep("_", messageLength) 
		end
	end

@PapaBreadd
@PoppyandNeivaarecute

1 Like

try this:

local function UpdateTextFunction(messageObject)
		if messageData.IsFiltered then
			BaseMessage.Text = string.rep(" ", numNeededSpaces) .. BaseMessage.Text:gsub("^%l",function(a) return a:upper() end):gsub("[^%.]$",function(a) return a.."." end)
		else
			local messageLength = messageObject.MessageLengthUtf8 or messageObject.MessageLength
			BaseMessage.Text = string.rep(" ", numNeededSpaces) .. string.rep("_", messageLength) 
		end
	end

Oh sorry I meant messageObject.Message, not BaseMessage.Message

image

Yeah that doesn’t work very well… :confused:

?
@PapaBreadd @SeargentAUS

Is that image my code or his?

Would you mind showing what you currently have for code

I dont really use modified chat, but you could try this:

local function UpdateTextFunction(messageObject)
	if messageData.IsFiltered then
			BaseMessage.Text = string.rep(" ", numNeededSpaces) .. BaseMessage.Text:gsub("^%l",function(a) return a:upper() end):gsub("[^%.]$",function(a) return a.."." end)
	else
		local messageLength = messageObject.MessageLengthUtf8 or messageObject.MessageLength
		BaseMessage.Text = string.rep(" ", numNeededSpaces) .. string.rep("_", messageLength) 
	end
return BaseMessage.Text
end

Adding the return may actually fix it

The code below works perfectly for me

local function UpdateTextFunction(messageObject)
	if messageData.IsFiltered then
		BaseMessage.Text = string.rep(" ", numNeededSpaces) .. messageObject.Message:gsub("^%l",function(a) return a:upper() end):gsub("[^%.]$",function(a) return a.."." end)
	else
		local messageLength = messageObject.MessageLengthUtf8 or messageObject.MessageLength
		BaseMessage.Text = string.rep(" ", numNeededSpaces) .. string.rep("_", messageLength)
	end
end

All you have to do is paste

:gsub("^%l",function(a) return a:upper() end):gsub("[^%.]$",function(a) return a.."." end)

To the end of whats there by default

1 Like

Pog it works, just not in bubblechat xD