Coming back to this now, one actor, multiple scripts and using ConnectParallel is definitely the right move for my task. Even with a single Heartbeat connection with nothing inside of it, the script activity could jump to 0.3% without using what I just said.
Originally I had one actor and one script, which could essentially slow down the script when iterating through ~20 players, causing false positives. I avoided it by using task.spawn but parallel lua seems like a much more reliable option.
I tried one script and actor per player, however it still drove up script activity when it got to around 20 players. However with one actor and a script per player (under the same actor) it works perfectly. No slowdown and no script activity spikes.
20 scripts not using Parallel Lua.
20 scripts using Parallel Lua. (ALL SCRIPTS UNDER ONE ACTOR)
20 scripts using Parallel Lua. (ALL SCRIPTS UNDER ITS OWN ACTOR)
All scripts had this context:
local a = 0
game["Run Service"].Heartbeat:ConnectParallel(function(DeltaTime)
a+=1
end)
Nothing heavy really, but still worth something.
Back here for the final time I promise, this is just for any possible lurkers that are interested in parallel lua but don’t know if it’s worth the switchover.
This is my anticheat with 8 players with parallel lua enabled: (Note that it never reached over 0.5%, it always stayed inbetween .488 and 0. Rarely reaching .488)
Here’s the same anticheat without parallel lua: (Note that this reached up to 1% per player, the screenshot just didn’t get that)
While to be fair there are differences in the scripts that probably make the parallel lua run faster not because it’s parallel but because I could create more optimizations just because it was parallel, it’s pretty insane how much of a difference parallel lua can make.