game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ Text = "Welcome to Ghost in the Graveyard!"; Color = Color3.fromRGB(255,255,255); Font = Enum.Font.SourceSans; FontSize = Enum.FontSize.Size24; }) wait(2) game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ Text = "Happy Halloween from TickTock Productions!"; Color = Color3.fromRGB(255,165,0); Font = Enum.Font.SourceSans; FontSize = Enum.FontSize.Size24; })
You can make it more efficient by saving repeated expressions to local variables (in this case, local starterGui = game:GetService("StarterGui")
). You can prevent the duplicate code by using a function:
local starterGui = game:GetService("StarterGui") local defaultColor = Color3.fromRGB(255,255,255) function SetMessage(text, color, font, fontSize) -- all arguments except 'text' are optional starterGui:SetCore("ChatMakeSystemMessage", { Text = text or error("Text is nil"), Color = color or defaultColor, Font = font or Enum.Font.SourceSans, FontSize = fontSize or Enum.FontSize.Size24, }) end SetMessage("Welcome to Ghost in the Graveyard!") wait(2) SetMessage("Happy Halloween from TickTock Productions!")
(I put commas in the table, but your semicolons work too.)
[Edit]
You ask about how to make it a server script. To comply with FilteringEnabled, you have to break it up into two pieces: what the server will do and what the client will do. The client must always be responsible for the gui, but should never be responsible for keeping track of important information (like how much money someone has). The client also never has access to things like Datastores. Whatever the client cannot or should not do, the server must do instead.
If your intent is to make the server be able to specify new messages (ex game updates), you will need a RemoteEvent. The server should fire it whenever it wants the client to display a specific message and the client should listen for it and update the text.
You can use a while loop with a wait parameter that fires that code every 'x' seconds and get a random message from a table.
local messageTable = { --If you're going to add more make sure they're seperated by a comma besides the last one "Welcome to Ghost in the Graveyard!", "Happy Halloween from TickTock Productions!" } local waitTime = 30; --Time we wanna wait after every message while wait(waitTime) do local randomMessage = messageTable[math.random(1,#messageTable)] game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ Text = randomMessage; Color = Color3.fromRGB(255,255,255); Font = Enum.Font.SourceSans; FontSize = Enum.FontSize.Size24; }) end --I believe having the wait() inside the condition works better so it doesn't run at the beginning of the script.
Few other tricks but I think this is the best way.