Custom text channels

Hello! I am trying to achieve having custom text channels for admins and removing the team channel.
What I’ve done is remove the standard chats, add the admin chat and a general chat. Now the problem is that when I join i have access to these chats but it doesn’t automatically set me in the General chat (or any other chat either), which means i have to press the General chat from the topbar to start chatting.

local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")

local AdminModule = require(game.ServerScriptService.AdminServer.AdminModule)

local Channels = {
	{
		Name = "DevChat",
		JoinRequirement = function(player)
			local rank = AdminModule.GetUserRank(player,false)
			return rank >= 201
		end
	},
	{
		Name = "ModeratorChat",
		JoinRequirement = function(player)
			local rank = AdminModule.GetUserRank(player,false)
			return rank >= 101
		end
	},
	{
		Name = "General",
		JoinRequirement = function(player)
			return true
		end
	},
}

local ChannelObjects = {}

for _, info in ipairs(Channels) do 
	local channel = Instance.new("TextChannel") 
	channel.Name = info.Name
	channel.Parent = TextChatService 
	ChannelObjects[info.Name] = { 
		Instance = channel, 
		Requirement = info.JoinRequirement 
	} 
end

Players.PlayerAdded:Connect(function(player)
	for name, data in pairs(ChannelObjects) do
		if data.Requirement(player) then
			data.Instance:AddUserAsync(player.UserId)
		end
	end
end)

Thanks in advance!

by default, the chat would use the default text channel, but since you’re disabling you need to set it manually.

you can set ChatInputBarConfiguration’s TargetTextChannel property to a TextChannel like “General” at the start and it’ll be selected by default.

a ChatInputBarConfiguration instance can be found inside TextChatService as a child

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.