My Gamemode Lags/Crashes Without Reason

I have been coding a simple round-based TDM gamemode. So far, I have fixed all Lua errors which show up (with some help, I am a beginner).

When I start a singleplayer game, I start to lag. The lag becomes worse. Then, I crash.

I checked Task Manager while ingame, and found CPU-usage steadily rising until it reaches its maximum (then I crash).

I added -condebug to the launch options, but did not find any errors in the console.log file after I crashed.

I do not necessarily need a fix, I would just like to know what is causing this lag.

Here’s the init.lua: (The paste will expire in two weeks)

Is the crash serverside or clientside? I’m guessing clientside…

Make sure you don’t use Material, surface.CreateFont, vgui.Create, etc… in HUDPaint or any hook which runs every frame… Create once, then use many times. Your crash seems to match the profile of a memory leak / issue caused by creating something many times over.

I indeed use surface.CreateFont in the HUD to show the Health/Armor amounts. Is there an alternative?

Just have it in the file, not any functions/hooks