Chat
The Chat service provides functionality for creating and managing chat channels to dictate how players communicate with each other, as well as how receiving messages work in the game.
Properties
An event that is fired by the server to all clients when a channel is destroyed. Class.ChannelInfo is passed as the parameter.
Chat.ChannelDestroyed:Connect(function(channel)
print("Channel " .. channel.name .. " has been destroyed.")
end)
An event that is fired by the server to all clients in the same channel as the player that left. Class.ChannelInfo and Class.Player are passed as the parameters.
Chat.PlayerLeftChannel:Connect(function(channel, player)
print(player.name .. " has left the channel.")
end)
An event that is fired when a client receives a text message. If this event has no connected listeners, the text message will display normally.
If you connect to this event to do custom messaging logic, use the DisplayTextMessage method to send the final results.
Class.ChannelInfo, Class.Player (the sender), and string are passed as the parameters.
Chat.TextMessageReceivedHandler:Connect(function(channel, player, message)
Chat:DisplayTextMessage(channel, player, message)
end)
The chat channel the local player is currently active in
All chat channels that exist in the game.
Methods
Adds the given player to the given channel.
local channel = Chat:CreateChannel("General", true, true)
server.PlayerConnected:Connect(function(player)
Chat:AddPlayerToChannel(channel, player)
end)
Parameters
channelInfo
player
Returns
Creates a new channel. If the channel already exists, it will return the existing channel.
local isGameRunning = true
local ghostChannel = Chat:CreateChannel("Ghost", true, false)
local generalChannel = Chat:CreateChannel("General", true, true)
server.PlayerConnected:Connect(function(player)
if isGameRunning then
Chat:AddPlayerToChannel(generalChannel, player) -- General channel is for players who are in the game
else
Chat:AddPlayerToChannel(ghostChannel, player) -- Ghost channel is for players who are not in the game
end
end)
Parameters
channelName
allowsText
allowsVoice
priority
Returns
Destroys the given channel, removing all players from it.
local generalChannel = Chat:CreateChannel("General", true, true)
server.PlayerConnected:Connect(function(player)
Chat:AddPlayerToChannel(generalChannel, player)
end)
server.PlayerDisconnected:Connect(function(player)
Chat:RemovePlayerFromChannel(generalChannel, player)
end)
server.PlayerLeft:Connect(function(player)
Chat:DestroyChannel(generalChannel)
end)
Parameters
channelInfo
Returns
Spawns a chat bubble at the given position with the given message and an optional nametag. The chat bubble will have the same appearance and lifespan as a normal player chat message.
Spawns a chat bubble at the given position with the given message and an optional nametag. The chat bubble will have the same appearance and lifespan as a normal player chat message.
Parameters
position
message
name
backgroundColor
fontColor
overrideChatBubbleSound
Returns
Spawns a chat bubble at the given position with the given message and an optional nametag. The chat bubble will have the same appearance and lifespan as a normal player chat message.
Parameters
position
message
name
overrideChatBubbleSound
Returns
Spawns a chat bubble at the given position with the given message and an optional nametag. The chat bubble will have the same appearance and lifespan as a normal player chat message.
Parameters
Returns
Parameters
Returns
Parameters
channel
from
message
language
backgroundColor
fontColor
overrideChatBubbleSound
Returns
Parameters
channel
from
message
language
overrideChatBubbleSound
Returns
Parameters
Returns
Gets the chat channel with the given name
Parameters
channelName
Returns
Parameters
player
Returns
Removes the given player from the given channel.
Parameters
channelInfo
player
Returns
Parameters
channelInfo
player
Returns
Updated 4 days ago