local chatservice = game:GetService("TextService")
local comservice = game:GetService("MessagingService")
local json = game:GetService("HttpService")
wait(3)
game.ReplicatedStorage.ChatEvent.OnServerEvent:Connect(function(plr, text, chat)
print(chat)
if chat == "Global" then
local sent = false
local data = {
id = plr.UserId,
txt = text,
name = plr.Name
}
local encoded = json:JSONEncode(data)
if not sent then
comservice:PublishAsync("Reaper's Chat Service", encoded)
sent = true
task.wait()
end
return "Success"
end
if chat == "Server" then
local label = game.ReplicatedStorage:FindFirstChild("Chat")
local inst = chatservice:FilterStringAsync(text, plr.UserId)
local newText = inst:GetNonChatStringForBroadcastAsync()
if newText then
print("string: "..text.." filtered for: Server Chat")
end
for i, v in pairs(game.Players:GetChildren()) do
if v:IsA("Player") then
local newLabel = label:Clone()
newLabel.Parent = v.PlayerGui.Chat.Server
task.wait(.03)
newLabel.nme.Text = plr.Name
newLabel.txt.Text = newText
end
end
end
end)
local function recieve(encoded)
local recieved = {}
local decoded = json:JSONDecode(encoded.Data)
wait(.5)
local text = decoded.txt
local id = decoded.id
local name = decoded.name
local label = game.ReplicatedStorage:FindFirstChild("Chat")
local inst = chatservice:FilterStringAsync(text, id)
local newText = inst:GetNonChatStringForBroadcastAsync()
if newText then
print("string: "..text.." filtered for: Global Chat")
end
print(newText)
print(name)
for i, v in pairs(game.Players:GetChildren()) do
print(v.Name)
local newLabel = label:Clone()
newLabel.Parent = v.PlayerGui.Chat.Global
task.wait(.03)
print(decoded)
print(typeof(name))
print(typeof(newText))
newLabel.nme.Text = name
newLabel.txt.Text = newText
end
end
comservice:SubscribeAsync("Reaper's Chat Service", recieve)
“Global”(cross server) chat does put the label in the chat… however only for the current server. it does not reach to other servers. any idea why?