Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

2 comments

0

I hope this helps

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.

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!!!")

This discussion is preserved as it was. New answers, comments, and votes are closed.