I've put the script in a local script since StarterGui:SetCore must be called from a local script and I've also put it in the StarterGui but it still doesn't work. I know the MakeChat function works, but when I add the function that connects it to a player joining it stops and doesn't print the text in chat.
function MakeChat(Msg,Color)
Color=Color or Color3.new(0,1,0)
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
Text = Msg;
Color = Color;
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size18;
})
end
function onPlayerEntered(nP)
MakeChat("[SERVER]: Welcome, "..nP.Name.."!", Color3.new(12,130,22));
end
game.Players.PlayerAdded:connect(onPlayerEntered)
Any clue on how to fix?
You could use a RemoteEvent to communicate between the server and client, which allows for you to manipulate the StarterGui from the server.
Server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Event = ReplicatedStorage:WaitForChild("RemoteEvent") function onPlayerEntered(nP) Event:FireClient(nP,"[SERVER]: Welcome, "..nP.Name.."!", Color3.new(12,130,22)) end game.Players.PlayerAdded:connect(onPlayerEntered)
LocalScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Event = ReplicatedStorage:WaitForChild("RemoteEvent") Event.OnClientEvent:Connect(function(msg,color) game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ Text = msg; Color = color or Color3.new(0,1,0); Font = Enum.Font.SourceSansBold; FontSize = Enum.FontSize.Size18; }) end)