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