Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

[SOLVED] How do I add a system message using text chat service?

Asked by 1 year ago
Edited 1 year ago

I'm trying to add a system message that says something when a user leaves or joins the game, but I'm using text chat service now, and it seems like there is a new solution to this, but I am unable to find out what it is. This is what my code looks like:

game.Players.PlayerAdded:Connect(function(plr)
    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
        Text = plr.Name.." joined the game.",
    })
    if (plr.UserId == 1274540012) then
        game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
            Text = "[OWNER] "..plr.Name.." joined the game.",
            Colour = Color3.fromRGB(0,215,255)
        })
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
        Text = plr.Name.." left the game.",
    })
    if (plr.UserId == 1274540012) then
        game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
            Text = "[OWNER] "..plr.Name.." left the game.",
            Colour = Color3.fromRGB(0,215,255)
        })
    end
end)

2 answers

Log in to vote
0
Answered by 1 year ago
game.Players.PlayerAdded:Connect(function(plr)
    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
        Text = plr.Name.." joined the game." -- unnecessary comma 
    })
    if (plr.UserId == 1274540012) then
        game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
            Text = "[OWNER] "..plr.Name.." joined the game.",
            Color = Color3.new(0,215,255)
        })
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
        Text = plr.Name.." left the game."
    })
    if (plr.UserId == 1274540012) then
        game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
            Text = "[OWNER] "..plr.Name.." left the game.",
            Color = Color3.new(0,215,255) -- You added a extra U unless you use it and .new is -- what I use
        })
    end
end)
0
I hope this helps Blueturtle8908 79 — 1y
0
That still doesn't work for text chat service, as that only works for the default chat. I added a solution since I figured it out myself. BoiBoi24T 63 — 1y
Ad
Log in to vote
0
Answered by 1 year ago

I figured it out from this on the dev forum. To make a system message using textchatservice, you need to use the DisplaySystemMessage() function on a specific text channel. Make sure to make it in a LOCAL SCRIPT!!!!!!!!! First, you need to get a variable for the text channel. I will use RBXSystem. Also, get a variable for textchatservice.

local chat = game:GetService("TextChatService")
local channel = chat:WaitForChild("TextChannels"):WaitForChild("RBXSystem")

Now, we are going to use the function on the text channel.

channel:DisplaySystemMessage()

Inside the function, put the message you want to message as a string as the argument.

channel:DisplaySystemMessage("Hello!!!")

The script should look like this:

local chat = game:GetService("TextChatService")
local channel = chat:WaitForChild("TextChannels"):WaitForChild("RBXSystem")
channel:DisplaySystemMessage("Hello!!!")

Answer this question