Types
--!strict
-- @zyos73
-- 08/01/25
export type PublicChannel = {
Type: "Public",
Name: string,
AutoJoin: boolean,
Register: () -> any
}
export type PrivateChannel = {
Type: "Private",
Name: string,
AllowedPlayers: {Player},
Register: () -> any
}
export type Instances =
PublicChannel |
PrivateChannel
export type InstanceSelection =
"PublicChannel" |
"PrivateChannel"
return nil
New Function
--!strict
-- @zyos73
-- 08/01/25
-- Modules
local Package = script.Parent.Parent
local Types = require(Package.Types)
-- Types
type InstanceSelection = Types.InstanceSelection
type Instances = Types.Instances
type PublicChannel = Types.PublicChannel
type PrivateChannel = Types.PrivateChannel
-- Instances
local Instance = Package.Instances
local instanceMap = {
PublicChannel = require(Package.Instances.PuplicChannel),
PrivateChannel = require(Package.Instances.PrivateChannel)
}
local function New(instanceType : InstanceSelection) : Instances
local instance = instanceMap[instanceType]()
return instance
end
return New
Executor Script
--!strict
-- @zyos73
-- 08/01/25
-- Modules
local TextChatServiceV2 = require(game.ServerScriptService.TextChatServiceV2)
local Types = require(game.ServerScriptService.TextChatServiceV2.Types)
local player = game.Players:WaitForChild("Zyozok")
local newPrivateChannel = TextChatServiceV2.New("PrivateChannel")
newPrivateChannel.AllowedPlayers = {player}
newPrivateChannel.Register()
local newPuplicChannel = TextChatServiceV2.New("PublicChannel")
newPuplicChannel.Register()
Im trying to create new Channels with TextChatServiceV2.New(type) which works but the problem is, because im trying to create more then 1 type over my New() function I can't tell which type the function is gonna return which breaks the auto complete. Does anyone have a idea how I can create multiple types with 1 function and still keep auto complete?


** You are now Level 25! **