Found a serious issue in my game and I don’t know what’s causing the problem exactly… I want to say about 1% of the time a server starts up, my server script will hang forever on this one block of code with no errors. No code below it runs, ever. I can’t provide any more information unfortunately because of how rare it is… I can’t just add prints or anything because it could still take 1000 tries to actually happen. But with the amount of people who play my game, it becomes an issue since 1 out of say 100 servers could be completely broken by it…
Anyways the block of code it hangs on is this:
local MessageService = game:GetService("MessagingService")
local Date = os.date("!*t")
local StatTopic = Date.month.."/"..Date.day
local ShutdownTopic = "SHUTDOWN"
function ServerSD(Mes)
SaveStats()
for i = 1,10 do
Event:FireAllClients("Chat", "SERVER", "SERVER RESTART INCOMING! Trying to save everyones' Data!", 300)
if Mes.Data ~= nil and Mes.Data ~= 0 then
Event:FireAllClients("Chat", "SERVER", Mes.Data, 300)
end
Cleanup(true)
wait(7)
end
end
local SDSucc, SDEvent = pcall(function() return MessageService:SubscribeAsync(ShutdownTopic, ServerSD) end)
local LastStats,DateStats = 0,0
local LastStatOutput = os.time()-230
function StatsUpdate(call)
DateStats = call.Data
if os.time()-LastStatOutput >= 300 then
LastStatOutput = os.time()
print(Date.month.."/"..Date.day.." stats: "..DateStats)
end
end
local StatSucc, StatEvent = pcall(function() return MessageService:SubscribeAsync(StatTopic, StatsUpdate) end)
I know that it’s in that specific block because I have event bindings just above it that work just fine when it hangs, and event bindings just below it that don’t work at all. I’ve renamed some things for “reasons” but the exact functionality of the code is there. Does anyone know why this would just hang forever with no errors? It seems to have started doing it just today, and this exact block worked perfectly fine as of yesterday.