Only errors I get involve plugins, and I get occasional infinite yield possible warnings for the gamepass scripts
It doesn’t crash when you play test in studio?
id have to try that, ill let you know the results
After going AFK for 40 minutes in studio, nothing happened. Only notable thing was my chat script timed out after 20 minutes
That is very likely the culprit. As I mentioned. This error happens when there is an infinite loop in a script, and roblox studio will catch that if it freezes for 10 seconds. However, I am not sure that protection is in live games, meaning that this error will instead freeze your game forever
I assume that chat script is custom? Could you show it, well the error seems to be around line 162
Here you go:
local TextChatService = game:GetService("TextChatService")
local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players").LocalPlayer
local SETTINGS = Players:FindFirstChild("Settings")
if not SETTINGS then
repeat
wait(0.2)
SETTINGS = Players:FindFirstChild("Settings")
until SETTINGS
end
local MessageDisplay = SETTINGS:FindFirstChild("SystemMessage")
if not MessageDisplay then
repeat
wait(0.2)
MessageDisplay = SETTINGS:FindFirstChild("SystemMessage")
until MessageDisplay
end
local function groupRankRGB(groupRank)
local r, g, b = 0,0,0
if groupRank == "Owner" then
r, g, b = 0, 0, 0
elseif groupRank == "Tester" then
r, g, b = 38, 137, 239
elseif groupRank == "Developer" then
r, g, b = 254, 28, 32
elseif groupRank == "Member" then
r, g, b = 57, 103, 254
end
return r, g, b
end
local function KnowRank(Player)
local ChatTagText = ""
local r, g, b = 0,0,0
if Player:IsInGroup(33852318) then
local groupRank = Player:GetRoleInGroup(33852318)
ChatTagText = "["..groupRank.."]"
r, g, b = groupRankRGB(groupRank)
end
local chat = {ChatTagText,r,g,b}
return chat
end
local function KnowGamepass(Player)
local Gamepass = Player:FindFirstChild("Data"):FindFirstChild("PlayerData")
if not Gamepass then
repeat
wait(0.25)
Gamepass = Player:FindFirstChild("Data"):FindFirstChild("PlayerData")
until Gamepass
end
local ULTRA = Gamepass:FindFirstChild("HasMVP")
if not ULTRA then
repeat
wait(0.25)
Gamepass:FindFirstChild("HasMVP")
until ULTRA
end
local VIP = Gamepass:FindFirstChild("HasVIP")
if not VIP then
repeat
wait(0.25)
Gamepass:FindFirstChild("HasVIP")
until VIP
end
local ChatTagText = ""
local r, g, b = 0,0,0
if VIP.Value == true and ULTRA.Value == true then
ChatTagText = "[MVP/VIP]"
r, g, b = 239, 26, 254
elseif ULTRA.Value == true then
ChatTagText = "[MVP]"
r, g, b = 254, 1, 1
elseif VIP.Value == true then
ChatTagText = "[VIP]"
r, g, b = 233, 254, 0
end
local chat = {ChatTagText,r,g,b}
return chat
end
TextChatService.OnIncomingMessage = function(Message: TextChatMessage) -- ChatRank System
local Properties = Instance.new("TextChatMessageProperties")
if Message.TextSource then
local Player = game:GetService("Players"):GetPlayerByUserId(Message.TextSource.UserId)
local info = KnowRank(Player)
local r1, g1, b1 = info[2], info[3], info[4]
local groupRank = info[1]
local info2 = KnowGamepass(Player)
local r2, g2, b2 = info2[2], info2[3], info2[4]
local gamepassRank = info2[1]
if gamepassRank ~= "" and groupRank ~= "" then
Properties.PrefixText = "<font color='rgb("..r1..","..g1..","..b1..")'>"..groupRank.."</font> " .. "<font color='rgb("..r2..","..g2..","..b2..")'>"..gamepassRank.."</font> ".. Message.PrefixText
elseif gamepassRank == "" and groupRank ~= "" then
Properties.PrefixText = "<font color='rgb("..r1..","..g1..","..b1..")'>"..groupRank.."</font> " .. Message.PrefixText
elseif gamepassRank ~= "" and groupRank == "" then
Properties.PrefixText = "<font color='rgb("..r2..","..g2..","..b2..")'>"..gamepassRank.."</font> ".. Message.PrefixText
else
Properties.PrefixText = Message.PrefixText
end
end
return Properties
end
-------------------------------------------------------------------------------------------------
local sysmessages = {
"Join our Discord server!",
"Like the game!",
"Favorite the game for more updates!",
"Join our roblox group for +1 Rune Luck, and a +x3 Multiplier boost!",
}
local tipmessages = {
"Purchase Runes and Upgrades to get better boosts!",
}
local lastMessageIndex1 = 0
local lastMessageIndex2 = 0
local prefix1 = "[System]: "
local prefix2 = "[Tip]: "
local deb = true
while wait(300) do
if MessageDisplay.Value == true then
if deb then
deb = false
local randomIndex = math.random(1, #sysmessages)
while randomIndex == lastMessageIndex1 do
randomIndex = math.random(1, #sysmessages)
end
lastMessageIndex1 = randomIndex
local randomMessage = sysmessages[randomIndex]
TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("<font color='#00FFEE'>" .. prefix1 .. randomMessage .. "</font>")
else
deb = true
local randomIndex = math.random(1, #tipmessages)
while randomIndex == lastMessageIndex2 do
randomIndex = math.random(1, #tipmessages)
end
lastMessageIndex2 = randomIndex
local randomMessage = tipmessages[randomIndex]
TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("<font color='#FFFFFF'>" .. prefix2 .. randomMessage .. "</font>")
end
end
end
Here is the issue
This while loop runs forever since the only possible index is 1 (the length of tipmessages is 1). Since lastMessageIndex2 will be 1 after it ran once, it will try to get an index different than 1, but will never succeed, because the only possible index is 1
The reason why it happens after about 20 minutes is because:
MessageDisplay.Value is possibly false, wait 5 minutes
It prints a sysmessage, wait 5 minutes
It prints a tipmessage, wait 5 minutes
It prints a systemmessage, wait 5 minutes
Tries to print a tipmessage, but gets stuck in that infinite loop
what can I do to fix this? I didn’t make this script, so I don’t really understand
An easy solution is to add another tipmessage, otherwise, you can improve the code like this:
while wait(300) do
if MessageDisplay.Value == true then
if deb then
deb = false
local _sysmessages = table.clone(sysmessages)
if #_sysmessages > 1 then table.remove(_sysmessages,lastMessageIndex1) end
local randomIndex = math.random(1, #_sysmessages)
lastMessageIndex1 = randomIndex
local randomMessage = _sysmessages[randomIndex]
TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("<font color='#00FFEE'>" .. prefix1 .. randomMessage .. "</font>")
else
deb = true
local _tipmessages = table.clone(tipmessages)
if #_tipmessages > 1 then table.remove(_tipmessages,lastMessageIndex2) end
local randomIndex = math.random(1, #_tipmessages)
lastMessageIndex2 = randomIndex
local randomMessage = _tipmessages[randomIndex]
TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("<font color='#FFFFFF'>" .. prefix2 .. randomMessage .. "</font>")
end
end
end
Replace the loop with the one above
Ohhh so the issue was there was only 1 tip message?
Well, in part, but I’d say mainly the code having a while loop that is vulnerable to infinite execution (which was triggered by having only 1 tip message)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.