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

How would you send a message to the chat globally?

Asked by
Hasburo 150
9 years ago
1game:GetService("StarterGui"):SetCore("SendNotification",{
2    Text = "test";
3    Title = "test";
4    Color = Color3.new(0,1,1)
5    })

So I've been told that SendNotification is an API, but it hasn't been developed yet.

1game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
2    Text = "Welcome, "..player.Name..".";
3    Color = Color3.new(0,1,1)
4})

However, there is ChatMakeSystemMessage, which is working. The problem I am running into is that I want it to display globally, meaning that every user can see the message, rather than just the LocalPlayer.

For those of you who don't know, the script has to be a LocalScript & located in the StarterGui. Help would be appreciated.

2 answers

Log in to vote
2
Answered by 9 years ago

I would use RemoteEvents for this. When you have a RemoteEvent all you do is call FireAllClients() and the same thing happens to everyone.

LocalScript in StarterGui:

1local plr   = game.Players.LocalPlayer
2local RE    = Instance.new("RemoteEvent", game.ReplicatedStorage)
3RE.Name = "Chat"
4RE.OnClientEvent:connect(function(msg, color)
5    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
6        Text = msg or "Hello, world!";
7        Color = color or Color3.new(0, 1, 1)
8    })
9end)

Script in ServerScriptService:

01local RE    = game.ReplicatedStorage:WaitForChild("Chat")
02 
03 
04-- welcome message
05game.Players.PlayerAdded:connect(function(plr)
06    RE:FireAllClients(plr.Name.." has joined the server.", Color3.new(0, 1, 0));
07end)
08 
09game.Players.PlayerRemoving:connect(function(plr)
10    RE:FireAllClients(plr.Name.." has left the server.", Color3.new(1, 0, 0);
11end)
12 
13-- general information messages
14local info = {"fav the game!", "thumb up the game pls!", "follow my twitter!"}
15 
View all 21 lines...
0
Well apart from the last bit completely spamming the chat & crashing the server, it didn't work. Hasburo 150 — 9y
0
Oops I forgot to put a wait(), there, now try it. 0xDEADC0DE 310 — 9y
0
Unfortunately, it's still not working. I mean, the general information part is, however the introduction message is not. Hasburo 150 — 9y
0
Now try the new script 0xDEADC0DE 310 — 9y
View all comments (4 more)
0
Still not working. Hasburo 150 — 9y
0
Works for me. 0xDEADC0DE 310 — 9y
0
The general information works, sure, but the introduction message does not. Hasburo 150 — 9y
0
The join message works for me lol 0xDEADC0DE 310 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

This method might be a bit barbarian, but it should work:

Put a StringValue named "Chat" in Workspace. Put this LocalScript in every Player.

1ChatValue = game.Workspace.Chat
2 
3Chat.Changed:connect(function(property)
4    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
5        Text = Chat.Value;
6        Color = color or Color3.new(0, 1, 1)})
7end)

And then have this Script in workspace too:

1game.Players.PlayerAdded:connect(function(player)
2    game.Workspace.Chat.Value = "Welcome, "..player.Name
3end)

I might have made me a mistake, if so, please contact me. If you'd need any further explanation, feel free to contact me too.

P.S. Please UpVote, so I can Upvote others! (I don't have 5 Rep yet)

Answer this question