#trying to create an ingame executable command e.g !command u can say in chat

1 messages · Page 1 of 1 (latest)

velvet portal
#

I want it to create another tab in chat that u click on like shown in the picture but it just isnt creating the new tab

local Players = game:GetService("Players")

local trainingCreated = false

TextChatService.OnIncomingMessage = function(message)
    local player = message.TextSource and Players:GetPlayerByUserId(message.TextSource.UserId)
    if not player then return end

    local msg = message.Text:lower()
    local chatUser = TextChatService:FindFirstChild(player.Name)

    if msg == "!trainingchat" then
        if not trainingCreated then
            local trainingChannel = Instance.new("TextChannel")
            trainingChannel.Name = "Training"
            trainingChannel.AutoJoin = false
            trainingChannel.Parent = TextChatService
            trainingCreated = true
        end

        local channel = TextChatService:FindFirstChild("Training")
        if chatUser and channel then
            channel:AddUserAsync(chatUser)
        end

        return nil 
    end

    if msg == "!endtraining" then
        local channel = TextChatService:FindFirstChild("Training")
        if chatUser and channel then
            channel:RemoveUserAsync(chatUser)
        end

        return nil
    end

    return message 
end

this is my script in serverscriptservice

twilit valve
#

roblox limitations

#

and this way it makes more sense either way

velvet portal
#

startpolayerscripts?

velvet portal
# twilit valve OnIncomingMessage method can only be applied in a client script
local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")

local player = Players.LocalPlayer

local function getOrCreateTrainingChannel()
    local existing = TextChatService:FindFirstChild("Training")
    if existing then return existing end

    local channel = Instance.new("TextChannel")
    channel.Name = "Training"
    channel.DisplayName = "Training"
    channel.Parent = TextChatService
    channel.AutoJoin = false
    return channel
end

player.Chatted:Connect(function(message)
    message = message:lower()

    if message == "!starttraining" then
        local trainingChannel = getOrCreateTrainingChannel()

        trainingChannel:JoinAsync()
        print("Joined Training channel.")

    elseif message == "!endtraining" then
        local channel = TextChatService:FindFirstChild("Training")
        if channel then
            channel:LeaveAsync()
            print("Left Training channel.")
        end
    end
end)

TextChatService.OnIncomingMessage = function(message)
    local props = Instance.new("TextChatMessageProperties")
    return props
end
#

stildont work

twilit valve
#

in abt to sleep, cant help w that rn

#

mb

velvet portal
#

alr

glossy thorn
#

you wanna do what?

velvet portal
#

in game command

#

for e.g

#

!starttraining

#

opens a new chat tab

#

and then

#

to end !endtraining closes the tab

glossy thorn
#

hm

velvet portal
glossy thorn
#

im sleepy