Chat message sending assistance

hello fellow robloxians
i am struggling a lot to send a message ive looked for tutorials but they are outdated and dont work , tried the assistant and same outdated scripts, looked through docs but found nothing useful and ive scouted through the forum and this is the best i could find

game.TextChatService:WaitForChild("TextChannels").RBXSystem:DisplaySystemMessage("test")

the local script is running on starter player scripts but it wont send any message and the script wont throw any errors, help wanted1!1!

1 Like

Doesn’t it need on the server sss

Your code is fine. The new chat system just takes a moment to initialize. Use task.wait to wait for ~1 second before sending the message. Unfortunately, I do not know of a way to understand when the service is properly ready

replying to SubToParcIeDev_onyt:
the function DisplaSystemMessage only runs client-sided only so it wouldnt work on a server script
replying to Ziffix:
my code wasnt fine but i added wait and it worked just fine like this

wait(2)
game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("test")
-- feel free to use the script :p

Wouldn’t that make my answer the solution? Slide the credit, man :joy:

as i said, your answer wasnt completly the solution, i had to remove wait for child if you noticed but sure lol

WaitForChild has no affect on the problem

well for me it only worked after i removed it : /

Try adding it back :person_shrugging:

I used WaitForChild in my test before first responding to your problem. It’s generally a good practice to use that function on the client

your right i tought i added it in server but that script actualy sended a remote event to the local script

i used it like this

local TCS = game:GetService("TextChatService")

event.OnClientEvent:Connect(function(Masage, channel)
	local textChannel

	if channel == "Private" then
		textChannel = TCS:WaitForChild("TextChannels"):WaitForChild("Private"..player.UserId)
	elseif channel == "General" then
		textChannel = TCS:WaitForChild("TextChannels"):WaitForChild("RBXGeneral")

	end
	textChannel:DisplaySystemMessage(Masage)

end)

-- also on the server 	
local TCS = game:GetService("TextChatService")

local remote = 

local plr = game:GetService("Players")

plr.PlayerAdded:Connect(function(player: Player) 
	task.wait(2)
	local privateChannel = Instance.new("TextChannel")
	privateChannel.Name = "Private"..player.UserId
	privateChannel.Parent = TCS:FindFirstChild("TextChannels")	

        remote:FireAllClients('<font color="#55ff00">'..player.Name..' have joined the game </font>',"General")
end)

```
1 Like

i ̶c̶o̶u̶l̶d̶ will elaborate further why in this scenario its better not to use it but i will give you two words: saves memory: WaitForChild blocks the script’s execution until the child is found unless the child already exists but if it already exists(which it does because the script works when referencing directly) then theres no reason to not just reference it directly and if you know about bits you´ll know writing “:WaitForChild(“TextChannels”)”
takes up more bits than “wait(2)” and “.TextChannels” and each bit requires a small amount of memory to be stored and while the memory saving its not noticeable at all its there, not saying waitforchild is bad tho it doesnt work for me in this script for some reason, and what is that additional image like i know using waitforchild is a good practice u dont have to tell me that

Two words: entirely negligible.

Additionally:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.