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!
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.
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.
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.