TextChannel:DisplaySystemMessage() not working

Hello,

I’m Trying to send messages in chat to the localplayer, not the server, but for some reason its not working, and im not sure why, looked on several devfoum posts and they do not help either–there is no message in the chat or any errors what so ever, i really need help on this thanks!

Heres the code:

2 Likes

Apologies, i found a fix, might as well keep the post open for other people to see. Found that adding a task.wait(2) at the top of the local script fixes this issue, probably because the chat and functions havent loaded before the code actually runs maybe, but anyhow heres the code:

task.wait(2) -- i would say 2 would be the minimum, higher the better of a chance it will send rather than not.

local TextChatService = game:GetService("TextChatService")
local TextChannels = TextChatService:WaitForChild("TextChannels") -- waitforchild is pointless when adding a wait at top but better be safe than sorry.
local SystemChannel: TextChannel = TextChannels:WaitForChild("RBXSystem") -- waitforchild is pointless when adding a wait at top but better be safe than sorry.


local success, response = pcall(function() -- if any errors get thrown or it fails to send the code wont break with it being wrapped in a pcall function.
	SystemChannel:DisplaySystemMessage("Your amazingly dull message!")
end)

print(tostring(success), tostring(response) -- lets you know if it sent or didnt i suppose.
1 Like

please tell me why you put local SystemChannel : TextChannel = instead of rather local SystemChannel =

1 Like

thats just typechecking which helps you a lot for the autocomplete to recognize the type of the variable and suggest related properties/methods

the “: TextChannel” at the end just tells you what its supposed to be, and also unlocks the properties, functions, events and all that for that specific object, so say if you said “local plr: Player = game.Players.LocalPlayer” it will show you more properties and what not in the little box that contains events, functions, and all that, just makes it easier to type quicker in code.

ye thats the right word i couldent think of it.

thanks buddy, I was figuring it out and I came to a conclusion that it just sets it as a type for yourself and wondered why the other stuff popped up when they didn’t before.

thank you for the information kind man

1 Like

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