Alright, so what I want to do is make a simple system message. I searched up a video on how and I used the same script.
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg:sub(1,3) == "-m " then
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = msg:gsub("-m ", "", 1);
Color = Color3.fromRGB(68, 255, 65)
})
end
end)
end)
I ran the game, said “-m test” but nothing happened. System didn’t chat in the chatbox. And yes I’m using legacy chat but it won’t work. I tried everything but nothing worked.
If anyone can help, it’ll be greatly appreciated since I really need this feature in my game.
It needs to be in a local script (the ChatMakeSystemMessage), so change it if it is not already.
Additionally, you should have it loop through all players currently in game (for _, player in game.Players:GetPlayers())), and apply the same plr.Chatted code to them.
Additionally, if you do move this to the client like @SeargentAUS said, it’s important to note Player.Chatted does not fire on the client, so you need some kind of alternative.
I think ChatMakeSystemMessage works on both client and server. I searched it up.
And I think the Player:Chatted() event should run fine when a player joins.
Also tried your method like this:
Server
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg:sub(1, 2) == "-lm" then
game.ReplicatedStorage.Test:FireAllClients(msg:gsub("-lm ", "", 1))
end
end)
end)
Client
game.ReplicatedStorage.Test.OnClientEvent:Connect(function(msg)
script.Parent:SetCore("ChatMakeSystemMessage", {
Text = msg;
Color = Color3.fromRGB(138, 255, 102)
})
end)