I have a table that constantly updates the subtables : Survivors, Zombies.
Explosion functions, bullet functions, zombiearm touch functions etc. All use same table to check who they hit, where enemies are etc.
Ever since this was added my game has been experiencing extremly frequent crashes. I’ve monitored this list and it doesn’t hog up on old data. Only the players/mobs available are listed.
What seems to be happening is that if multiple scripts access this table at same time it creates tremendous lag.
Is this possible or could something else be causing this extreme lag?
If you add debug.profilebegin() and debug.profileend() to your code you can actually see this custom labels popping up. It takes some knowledge to be able to read the Microprofiler, but ROBLOX has documented it quite well. You can also dump the microprofiler to your localmachine, so you can analyse it in peace
It also sounds like you don’t do garbage collection like you should, perhaps take a look or that is the case ?
You should try using the lua debugger, it can prevent studio from freezing from stuff like this:
You can use it to inspect the table if it’s not cyclic. Just add a breakpoint on the line after you have a reference to it.
Beware that you cannot step into metamethods, because they cannot yield.
Do not use print at a very fast rate, it can cause lag to write to the disk or to render.
How are you achieving multiple script access?
Do you have any metatables?
Which scripts and functions are writing? Which are reading? At what rate?
How are you monitoring the list right now?
I suppose you have a similiar setup to:
root table
Survivors
Zombies
How many references do you have on any of these tables?
I imagine the table is in a ModuleScript, and he’s changing values that way. That’s what I’m doing for my RPG game and it’s been working fine so far. @PlaceRebuilder Are you removing references to players or enemies once they have been removed from the game? Over time, this could build up and create a lot of useless references.
I don’t have enough enough information and so I can’t know wether the tables you are using
are the cause of the crashes. I will suppose your game is built this way:
TARGETS (stored in a modulescript)
Survivors
{Name, Torso, Humanoid, Player, Char, isSurvivor}
…
Zombies
{Name, Torso, Humanoid, Player, Char, isSurvivor}
…
Enemies
{Name, Torso, Humanoid, Player, Char, isSurvivor}
…
Wether modifying tables crash a game or not is place-specific, it can be caused by scripts that have a bad table management causing infinite loops, serilialization, etc.
Is the table kept on the server or the client too? How are you replicating it’s structure?
I suppose this is due to using multiple scripts, they could be hogging memory?
The only I think I could have seen as the cause of the lag is the same of this post