Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a chat message from the server?

So, I have the script that makes a chat, but I don't know how to make it where you can make custom messages when you're name is right (I've got this) but also randomly generated ones every 60 seconds...

To make the chat :/

game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
    Text = "Matter maketh man"; 
    Color = Color3.new(0,0,0); 
    Font = Enum.Font.SourceSansBold; 
    FontSize = Enum.FontSize.Size24; 
})

Random messages -- Color

local messages = {
["Remember to thumbs up and favorite!"] = true, --255, 255, 224
["Don't spam or be banned!"] = true, --0,0,0 
["Want mod or admin privileges, join the group!"] = true, --135, 206, 235
["Remember, we drive on the LEFT of the road!"] = true, --255, 255, 224
["Remember to enjoy yourself."] = true -- 135, 206, 235
}

1 answer

✓ Accepted answer

To get a random entry from an array, use math.random with the length of the table.

local randomMessage = messages[math.random(#messages)]

To put that into a message, it's the same thing.

Text = messages[math.random(#messages)]

To do it every 60 seconds, just put it in an infinite while loop with a wait(60) following your SetCore


Edit:
To do it with the color, you'll need to put the colors in an array too, or put the stuff in arrays of arrays.

Example:

messages = {
{"One little piggy went to market", Color3.new(0,0.5,1)},
{"Give the dog a bone", Color3.new(1,0.5,0)},
{"etc etc", Color3.new(0,0,0)}
}

Then, to get the random message and accompanying color, just choose a random entry

local random = messages[math.random(#messages)]

And then plug that into your code

Text = random[1],
Color = random[2]

woof woof

6 comments

0

Downvoting my answers because he edited it for more context when I was writing is not cool. I hope you're proud of yourself.

0

And for the color?

0

And I down-voted the first one, which wasn't an answer....

0

Doesn't matter. I don't have enough rep to comment, and your question at the time didn't have enough time for me to determine what you meant. Because I wanted to help you, I thought I'd kindly ask you to put more information in the only way available to me.

0

Dude. All you said was "I don't understand >.<

0

Yes, as in "I don't understand your question"

This discussion is preserved as it was. New answers, comments, and votes are closed.