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
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
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)
```
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