local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
if not ChatService:GetChannel("All") then
while true do
local ChannelName = ChatService.ChannelAdded:Wait()
if ChannelName == "All" then
break
end
end
end
local serverSpeaker = ChatService:AddSpeaker("Server")
serverSpeaker:JoinChannel("All")
local pl = --blablabla, getting the player I need to message
serverSpeaker:SendMessage("Messaging",ChatService:GetSpeaker(pl.Name))
I want to send a private message to a specific player, but it errors on the last line.
How to send private message to a specific player from chat speaker?
In your original code you did not specify the channel, not sure why my fix wont work though.
Anyway here is the arguments for SendMessage, note how fromSpeaker is a string and not a ChatSpeaker
I read the documentation, it is incredibly unprecise and confusing, like it doesnt explain anywhere what is “fromSpeaker”, is it the speaker that sends the message, is it the speaker To Whom the message is sent, is it the parliament speaker, is it a car stereo speaker?
The documentation is old and outdated, you can infer that the “fromSpeaker” is the target you are sending the message to, and that the ChatSpeaker you are calling the SendMessage method on is the sender.
Also this doesn’t seem right, 2nd argument is the channel. If you are sending a private message, why are you using the “All” channel?
But anyway I tried it and it didn’t work.
Here’s the modified code by the way, everything else is the same as in original post, just the portion where it should send the message is modified
if #players:GetChildren() < 5 then
--less than 5 cant initiate
print(pl.Name)
serverSpeaker:SendMessage("Can't initiate votekick with less than 5 players.", "All", pl.Name)
return
end
It prints the pl.Name correctly, but doesnt send anything in the chat