I'm trying to make an automatic chat system that the server makes. Every 7 minutes, the server sided script picks a phrase from a table called Texts and the server will be ready to bring that phrase to the client side. But when the client receives that information, it displays everything that was inside the table instead of picking one of the phrases. What am i doing wrong?
Server-Sided:
local SendMessage = game.ReplicatedStorage:WaitForChild("SendMessage")
Texts = {
"[Info]: Remember to Leave a Like and Favorite on the game!";
"[Info]: Check out the Store for useful Products and Passes!";
"[Tip]: You can collect Gems by searching all over the map!";
"[Info]: There is a hidden treasure chest in the map and it will reveal a code!";
"[Tip]: You can customize your gaming preference in the settings button!"
}
while true do
--wait(420)
wait(420)
for _, text in ipairs(Texts) do
SendMessage:FireAllClients({
Text = Texts[math.random(1,#Texts)];
Font = Enum.Font.SourceSansBold;
Color = Color3.fromRGB(255, 255, 0);
FontSize = Enum.FontSize.Size96;
})
end
end
Client-Sided:
local SendMessage = game.ReplicatedStorage:WaitForChild("SendMessage")
SendMessage.OnClientEvent:Connect(function(chatProperties)
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",chatProperties)
end)

1 comment
You are looping through all of the strings in the table with the ipairs iterator. What do you expect?