How to Make a Random System Chat Message Appear

Hello! Welcome back to another tutorial Today we will be making a System Chat Message that chooses a random message.
Lets Get Started.

First, Off we need to Make a Local Script and Make sure to set its parent as ScreenGui.

Name the Local Script “Main” and Make a Module script as the Child and Name that “Messages”

For The Module script you Just want to enter the tags you want to show up.

Here is an Example:

local module = { 
	"{System}: Enjoying game? Why not make the Experience better by buying gamepasses";
	"{System}: Don't Forget to tell all your friends about this game",
	"{System}: Enjoying the game? Be sure to like, favourite, and follow to be updated when were updated",
-- Example Chat Messages
	
}
return module

Next, Thing We need to define this module in our Local script to do that we have to require it.

local messageModule = require(script:WaitForChild("Messages"))

Now, We want to make it loop so it displays more than 1 chat message to do that we will use a while loop.

local messageModule = require(script:WaitForChild("Messages"))

while true do

end -- ends while loop

For the game to choose a random Message we will need to use math.random to pick one out of absolute random

local messageModule = require(script:WaitForChild("Messages"))

while true do
	local randomMessage =  messageModule[math.random(1, #messageModule)] -- # means how many there are so we currently have 3
end

Now Finally we want to make it print out the message in the chat and also appear in chat after a certain amount of seconds

local messageModule = require(script:WaitForChild("Messages"))

while true do
	local randomMessage =  messageModule[math.random(1, #messageModule)]
	
	game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
		Text = randomMessage;
		Color = Color3.fromRGB(255,0,0); -- These Colours are In RGB or Color3 Change it to what you want this Colour is Really red
			
		})
		
	wait(50)-- Amount of time until the random Message Shows Up -- Also so game dosent crash/lag -- Change it to what you want
end

There we go It should be working
Please Like this tutorial if we get a lot of likes I might make a tutorial video sires
Test Game : Chat Message Test Place - Roblox
Please Comment any questions or Concerns

Update: I Now Have A Youtube Channel I may make a tutorial of this going more in deep click here to subscribe

30 Likes

Quite a helpful tutorial! Hats off to you my friend! :smiley:

3 Likes

I found find it easier to use a table than a module script.

2 Likes

Ok What ever suits you thanks for the feedback.

1 Like

I would like to note that Color3.new() takes decimal numbers between 0-1. If you are looking to use numbers between 0-255, you should use RGB. You would do Color3.fromRGB(255,0,0) instead. Take a look here.

1 Like

Ok thank you for the feedback I will remember to use Color3.fromRGB next time.

Would a ModuleScript really be necessary here when we can just have the table in the same script? A ModuleScript would be redundant for this case unless we would use this same table in another script.

Edit: I’d also like to mention that the LocalScript doesn’t have to be parented to a ScreenGui for this to work, it can be parented to anything where it runs.

1 Like

I made the Parent of Local Script Screen GUI Because when I put it in other places it doesn’t run I have the best results in Screen GUI and I might make another tutorial with a table

What other places did you put it in? LocalScripts run in ReplicatedFirst, a player’s PlayerGui, a player’s PlayerScripts, a player’s Backpack, and a player’s character.

1 Like