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
8 years ago
game:GetService("StarterGui"):SetCore("SendNotification",{
    Text = "test";
    Title = "test";
    Color = Color3.new(0,1,1)
    })

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

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

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 8 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:

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

Script in ServerScriptService:

local RE    = game.ReplicatedStorage:WaitForChild("Chat")


-- welcome message
game.Players.PlayerAdded:connect(function(plr)
    RE:FireAllClients(plr.Name.." has joined the server.", Color3.new(0, 1, 0));
end)

game.Players.PlayerRemoving:connect(function(plr)
    RE:FireAllClients(plr.Name.." has left the server.", Color3.new(1, 0, 0);
end)

-- general information messages
local info = {"fav the game!", "thumb up the game pls!", "follow my twitter!"}

while true do
    for i,v in next, info do
        RE:FireAllClients(v, Color3.new(BrickColor.Random().Color))
        wait(15)
    end
end
0
Well apart from the last bit completely spamming the chat & crashing the server, it didn't work. Hasburo 150 — 8y
0
Oops I forgot to put a wait(), there, now try it. 0xDEADC0DE 310 — 8y
0
Unfortunately, it's still not working. I mean, the general information part is, however the introduction message is not. Hasburo 150 — 8y
0
Now try the new script 0xDEADC0DE 310 — 8y
View all comments (4 more)
0
Still not working. Hasburo 150 — 8y
0
Works for me. 0xDEADC0DE 310 — 8y
0
The general information works, sure, but the introduction message does not. Hasburo 150 — 8y
0
The join message works for me lol 0xDEADC0DE 310 — 8y
Ad
Log in to vote
1
Answered by 8 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.

ChatValue = game.Workspace.Chat

Chat.Changed:connect(function(property)
    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
        Text = Chat.Value;
        Color = color or Color3.new(0, 1, 1)})
end)

And then have this Script in workspace too:

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

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