I don’t really know much about TextChatService, and when I tried this code out, it gave me the error: Infinite yield possible on ‘TextChatService:WaitForChild(“TextChannels”)’.
local function generateSystemMsg(MsgDict : array)
return '<font color="#'..MsgDict["Color"]..'"><FontSize="'..MsgDict["FontSize"]..'"><Font face="'..MsgDict["Font"]..'">'..MsgDict["Text"]..'</font></font></font>'
end
local Choices = {
"Make sure you join the group and like and favorite the game!";
"Hi.";
"If you see any exploiters or bugs/glitches, please report them!";
"Sup."
}
while true do
local randomTip = math.random(1, #Choices)
local pickedTip = Choices[randomTip]
local chat = game:GetService("TextChatService")
local channel = chat:WaitForChild("TextChannels"):WaitForChild("RBXSystem")
channel:DisplaySystemMessage(
generateSystemMsg({
Text = "[SYSTEM] "..tostring(pickedTip);
Font = "Gotham";
Color = Color3.fromRGB(255, 0, 0):ToHex();
FontSize = "17";
})
)
task.wait(1)
end
If you think you know what went wrong, pls let me know. Thank you in advance.
My guess is you maybe put it in the wrong place? I added it to a LocalScript inside StarterPlayer/StarterPlayerScripts and I didn’t receive an error. Also you want to move the 2 lines where you set up chat and channel outside of your while loop. No need to keep getting those services and channels over and over.
Oh something else you can check is to make sure you have the ChatVersion setting correct in the TextChatService in the explorer. If you have it set to LegacyChatSystem you will get this error.
Here is a correction for your function also:
local function generateSystemMsg(MsgDict : array)
return '<font color="#'..MsgDict["Color"]..'" size="'..MsgDict["FontSize"]..'" face="'..MsgDict["Font"]..'">'..MsgDict["Text"]..'</font>'
end
You are mistaken. If you have LegacyChatSystem set it will never add the TextChatService items to the game when you are running…therefore you will NEVER be able to execute that code in the script.