I am trying to make it so the dead people in my game can’t talk to the alive people. To do this I have used chat channels and created a channel called dead that the player joins after dying.
However, the people not in the dead channel can still see the dead channel chat and what the dead people say.
How could I fix this?
Script:
local ServerScriptService = game:GetService('ServerScriptService')
local ChatService = require(ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
local Dead = "Dead"
local Channel2 = ChatService:AddChannel(Dead)
Channel2.Joinable = false
Channel2.AutoJoin = false
Channel2.WelcomeMessage = "You are now dead"
Channel2.Private = true
Channel2.Leaveable = false
local function onPlayerChatted(PlayerName)
print("chat")
local plr = game.Players:FindFirstChild(PlayerName)
if not plr then return end
local Speaker = ChatService:GetSpeaker(PlayerName)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,118837169) then
Speaker:SetExtraData('Tags', {{TagText = 'Premium', TagColor = Color3.fromRGB(191, 0, 255)}})
end
while task.wait() do
if not plr then break end
if plr:WaitForChild("Alive").Value == false then
Speaker:SetExtraData('ChatColor', Color3.fromRGB(111, 111, 111))
Speaker:SetExtraData('NameColor', Color3.fromRGB(74, 74, 74))
Speaker:JoinChannel(Dead) -- Joining channel works as it shows the welcome message
break
end
end
end
ChatService.SpeakerAdded:Connect(onPlayerChatted)