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)
Your script is set up to where every 420 seconds you go through the table the number of times that is equivalent to the amount of strings in your table. To fix this, simply take the for _, v loop out of the script.
Hope I helped!
-Cmgtotalyawesome