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

Why doesn't this create the message?

Asked by 6 years ago
Edited 6 years ago
game.Players.PlayerAdded:Connect(function(Player)
    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
    Text = "[SERVER] "..Player.Name.." has joined the game!";
    Color = Color3.new(0,1,0);
    Font = Enum.Font.SourceSans;
    FontSize = Enum.FontSize.Size24;
})
end)

0
This feature will only work in a LocalScript (or a ModuleScript running on the client) arshad145 392 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Put it in a LocalScript, running on the client, use RemoteEvents if necessary, e.g.

-- Client script
game.Workspace:WaitForChild("MakeAChat").OnClientEvent:Connect(function(msg)
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
    Text = "[SERVER]: " .. msg;
    Color = Color3.new(0,1,0);
    Font = Enum.Font.SourceSans;
    FontSize = Enum.FontSize.Size24;
})
end)
-- Server script
local remote = Instance.new("RemoteEvent")
remote.Parent = workspace
remote.Name = "MakeAChat"
game.Players.PlayerAdded:Connect(function(plr)
     remote:FireClient(plr, "Why, hello there!") -- Only sends message to player
     remote:FireAllClients(plr .. " has joined the game!") -- Sends message to everyone
end)

The upside to this, is you can send a message to only one client at a time, or to everyone by using FireAllClients()

Reference

0
Nicely done. AdministratorReece 193 — 6y
Ad

Answer this question