If you want to insert chat messages into a table if they begin and end with quotes, do this in a server script inside of ServerScriptService:
local messages = {}
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if (#message < 3) then return end
if ((message:sub(1, 1) == "\"") and (message:sub(#message, #message) == "\"")) then
table.insert(messages, message:sub(2, #message - 1))
end
end)
end)
Now, I wouldn't just throw a bunch of code at you without actually explaining what's being done.
We set up a table that'll hold all of the messages we want, and assign it to a variable called "messages."
Listen for whenever a player joins, and for whenever they chat.
Whenever they chat, make sure the message they're sending is at least 3 characters in length, because there needs to be at least 2 quotes, and a character in between them. If the length of the string is less than 3, exit out of the function.
Otherwise, check to see if the first character in the message is a quote, as well as if the last character in the message is a quote. If it is, then insert the message into the table, excluding the quotes.
3 comments
Are you trying insert strings into a table?
Nononono. I am trying to make it so when players type quotes in chat, it puts everything in between the quotes into a table
Nononono. I'm trying to make it so if users say something with quotes it puts everything inbetween the quotes into a table