LegacyChat ported to TextChatService

Really good! However, I found an issue with /c system.

External Media

It’s not a major bug, but for those of us with custom admin commands (like me), it’s unfortunate that we can’t use the system channel to hide our messages.

1 Like
Glazing

Very impressive what you have done. This has not been done by any of the other resources.

Personally, when making a resource like this, I found Legacy Chat code really large for no good reason at all, so I just decided recreate it instead.


Overall, it works really well. Only thing I would want here is an easier way to get the old Legacy Chat UI. This will probably come.


You could also add this link in the main post, as it provides some useful code examples and help:

2 Likes

Just a note: WinryChat isn’t a LegacyChat or a port of any chat system.
It’s a new one entirely to fix ROBLOX’s issues with TextChatService and Channel tabs.

3 Likes

It works fine and all but one little problem I saw with it was that when resizeing /activley doing it the scroll list keps moving up like it wont stay at the bottom

1 Like

Could you send a video? I don’t see what the unexpected behaviour is when doing it myself


I saw another post where you posted this old documentation page. I didn’t include it because it seems very similar to the existing documentation page, but there is that figure (the graph of how the chat system works) that is very nice
I do expect the existing documentation page to get removed probably past April 30th, so I will save an html of the page so people can still access it easily, though the new documentation site seems to be full of js…


Will fix! The error is very weird though, and I know /c system was working at some earlier point, unsure why that error is happening

Update: Changing the deprecated :TweenPosition() to TweenService fixed the issue. Cannot tell you why that error happens though

2 Likes

1 Like

you should use source sans, the font looks different on this

You can easily change the font in the ChatSettings module. You can use a Font object, or a Font enum, both are supported. The ChatSettings lua file provided to get the Classic look of the chat uses SourceSansBold

I chose Arimo because I used to have GothamSemibold as my font for the custom chat, and Arimo is a font I quite like, as a replacement for Gotham, now that it was removed


@LeoBeomkl, Interesting, it seems like stopping the resizing action and starting it again might be what is causing it. I added it to the list of known bugs, but it’s a low priority bug

– UPDATE –

Fixed multiple bugs (See the version 1.1 section)

This update should make this custom lua chat system stable, will see if more errors pop up though


Added settings for making the chat look like LegacyChat exactly



(These aren’t the settings to make it look like LegacyChat, see the ChatSettings.lua file)

If these settings are missing from your ChatSettings module, a default value is used instead. You can still use a ChatSettings module from version 1.0

I’ve noticed the size of the chat frame is smaller than how it was in the Legacy Chat when following these steps:

Here’s a comparison:
image

I found that it’s caused by the system using DefaultWindowSizeDesktop from the ChatSettings module. With normal Legacy Chat, it does not use it for some reason.


Also, this works whenever TextChatService.ChatVersion is set to LegacyChatService. Is this intentional?

1 Like

This is a bug I’ve fixed in my old thread:

Link to the quote above

I’m not quite sure what the correct size would be if you want to have the exact size of the LegacyChat. I think that bug was inconsistent, and so the size was inconsistent, but I am not sure (I went on a game that still used the LegacyChat, and got the DesktopSize). You can try to set DefaultWindowSizeDesktop to be the same as DefaultWindowSizeTablet


I have tried setting TextChatService.ChatVersion to LegacyChatService, and disabled Chat.LoadDefaultChat, and I get this error:
TextChatService is not enabled. Check TextChatService.ChatVersion and make sure it is not set as ChatVersion.LegacyChatService.

If I don’t disable Chat.LoadDefaultChat, I don’t get any errors, but every chat message seem to go through LegacyChat. The two are using the same EventFolder, and my guess is that the LegacyChat ends up taking over the CallbackFunction for the RemoteFunctions, making it so the custom Lua chat system isn’t throwing an error?

2 Likes

– UPDATE –

Fixed minor bugs, and added some features including (see section v1.2 for full list):
– Types! No more guessing if a method takes in the name of a speaker, or the speaker object itself. These types are applied to ChatService, ChatChannels, and Speaker by default, but are also available from the main Chat module
Note that the types do not include Internal functions, those that start with Internal
Channel.CanJoinFunction and Channel.CanLeaveFunction, for more control over whom can join a channel, instead of a boolean that acts upon every single speaker
Chat:GetChatService(), a more practical way to get ChatService

Here is a little code snipped for creating an admin channel, using some of the new features:

local Chat = require(game.ReplicatedStorage.Chat)
local ChatService = Chat:GetChatService() -- New v1.2 method to get ChatService, from Chat

local function CanJoinFunction(Speaker : Chat.Speaker)
	local Player = Speaker:GetPlayer()
	if not Player then return false end

	-- This could be modified to check if a player is in a group
	if not Player:GetAttribute("Admin") then return false end

	return true
end

local Channel = ChatService:AddChannel("Admin", false)
Channel.Private = true
Channel.CanJoinFunction = CanJoinFunction -- New property of Channel for complex join conditions
Channel.Leavable = true
Channel.WelcomeMessage = "This is a private channel for Admins"

ChatService.SpeakerAdded:Connect(function(SpeakerName : string) 
	local Speaker = ChatService:GetSpeaker(SpeakerName)
	
	local Player = Speaker:GetPlayer()
	if not Player then return end -- A non-player speaker
	
	-- Do an initial check to see if the speaker can join the channel
	-- Joinable/CanJoinFunction (and the ones for leaving) is only for /j, /join and /l or /leave
	if CanJoinFunction(Speaker) then
		Speaker:JoinChannel("Admin")
	end
	
	-- Automatically join and leave the channel as the attribute changes
	Player:GetAttributeChangedSignal("Admin"):Connect(function()
		if not Speaker:IsInChannel("Admin") then
			if not CanJoinFunction(Speaker) then return end
			
			Speaker:LeaveChannel("Admin")
		else 
			if CanJoinFunction(Speaker) then return end

			Speaker:SendSystemMessage("You've been kicked from the Admin channel as you are no longer an admin", "System")
			Speaker:LeaveChannel("Admin")
		end
	end)
end)
6 Likes

Does anyone know if my fork suffers from the same performance issues that plagues TextChatService?

TextChatService’s ui is disabled, but I’ve heard people say that disabling the ui doesn’t fix the lag issue. I’ve also heard that the performance issues only arise after some time (probably after a lot of messages have been sent). Has anyone used this fork in a game that has many players, or tested it in a server with many players?

My own game doesn’t have enough players for me to test this I don’t think, although there is one game, that isn’t mine but I’ve done some small things for, where I could update the chat to the forked version, and I might do that

Your input is appreciated :D

2 Likes

Love this! However, one issue. When I try to use :DisplaySystemMessage() I get an error saying:

ReplicatedStorage.Chat.ChatScript.ChatMain.TextChatServiceWrapper:44: table index is nil

Below is the script I tried using:

local function sysMsg(message)
	TextChatService.TextChannels_PortedChat.System:DisplaySystemMessage(message)
end

sysMsg("Hello!")

Thanks for making this port!

1 Like

My port of the Lua chat system doesn’t support calling the TextChannels directly, although you can destroy them to remove a Channel or Speaker
Supporting a direct call to TextChannels is not something I currently plan on adding

On the server, you can get the speaker from
ChatService:GetSpeaker(Player.Name), and then use Speaker:SendSystemMessage(message : string, channel : string?)

On the client I am not too sure, I know the client can send system messages to itself (the methods are in ChatMain I believe), but I don’t know if they can be accessed from outside scripts
You can use the StarterGui:SetCore(forgot the arguments) method to send system messages from the client, that one still works

I also haven’t added types for ChatMain on the client. This is something I’ll have to look into

3 Likes

I’ve tested the performance of both chats, and it’s actually very easy to replicate. ExperienceChatMain will be active when a message is sent. I don’t think it gets worse as more messages are added, although I did not test it after a while and just base this assumption on the fact it’s slow from the first message you send

However, I’ve also seen ExperienceChatMain take up a lot of cpu time when LegacyChat was being used, so it is possible that both LegacyChat and TextChatService suffer from performance issue. I do not know by how much this issue is exacerbated on TextChatService (assuming it is worse on TextChatService)

The default UI seems the same

Also, Topbar is another trouble maker, and seems to also cause lag spikes when a player chats, or shortly after?

Then you have PlayerListManager also taking several miliseconds…

I dunno if this is a known issue or if it’s just happening to me, but when I type the & key, after sending the message it turns into &, even if I was only trying to send the symbol (&)

image

1 Like

It’s probably due to TextChatService replacing some symbols into other characters.
Quite annoying to be honest.

1 Like

Interesting, seems like the reason is @Sun_Battery23238’s answer

I could probably match and replace it when the message is received, perhaps by marking & and others with one of the disallowed whitespace characters of the legacy chat, to mark those characters (or just assume people wont write & themselves and replace it directly)

1 Like

i just janked the module to response to .chatted functionality while you chat on system (also overwriten the bubble chat with ‘…’ for privaciyer)