I have been trying to have two separate chats, one for alive and other for dead but I’m getting really weird behaviour, after I use SetMainChannel
to either alive or dead and write a message, the other player from different channel can still see the message even tho I had channelName.Private = true
I tried to check if player joined the channel, and if the channel was set to mainchannel, and it was… I really have no idea what is going wrong
And when I tried ChatService:GetChannel('All'):MuteSpeaker(speakerName)
it didn’t allow me to chat saying (you are muted) and when I did ChatService:GetChannel('All'):KickSpeaker(speakerName)
it disabled the chat system (showing grey box with no text, and when I send message nothing happens) which tells that for some reason it’s using the “All” Channel instead of the channels I created, but I have no idea why.
local deadChannel = ChatService:AddChannel('DeadChannel')
deadChannel.Joinable = false
deadChannel.AutoJoin = false
deadChannel.Private = true
deadChannel.WelcomeMessage = 'TEST, DEAD DEAD DEAD!!! X_X' -- expect same for AliveChannel
ChatService.SpeakerAdded:Connect(function(speakerName)
local speaker = ChatService:GetSpeaker(speakerName)
speaker.ChannelJoined:Connect(function(channelName)
speaker:SetMainChannel(channelName)
end)
speaker:JoinChannel('DeadChannel')
end)
(the screen shot doesn’t include the welcome message, but don’t worry it appeared)
extra code
Set team to alive on round start
for _, player in pairs(players) do
local speaker = ChatService:GetSpeaker(player.Name)
speaker:LeaveChannel('DeadChannel')
speaker:JoinChannel('AliveChannel')
end
Join dead channel on death code
chara:WaitForChild('Humanoid').Died:Connect(function()
local speaker = ChatService:GetSpeaker(player.Name)
speaker:LeaveChannel('AliveChannel')
speaker:JoinChannel('DeadChannel')
end
Set channel to death on round end
for _, player in pairs(players) do
player:SetAttribute('Team', nil)
player:SetAttribute('Role', nil)
local speaker = ChatService:GetSpeaker(player.Name)
if speaker:IsInChannel('AliveChannel') then speaker:LeaveChannel('AliveChannel') end
speaker:JoinChannel('DeadChannel')
-- Other stuff