So all of my touched events suddenly stop working for like 3-30 seconds.
I have around 10K parts that have have CanTouch on, and I have a hitbox which touches them (Event done on client, however parts are serverside). There is only one event on hitbox, and needs to be fired with all the parts it touched with. When I run the game on a high end machine, event fires all the time. But once I get on to a lower end machine (In this case being my phone), touch events still work, but sometimes it literally stop firing for 3-30 seconds.
My best guess is that Touch starts “sleeping” after a certain FPS amount. I have absolutely no idea how to fix this.
My end goal is to make all touched events fire all the time regardless of device I use. How would I achieve that?
Having 10,000 Touch events fire at once would most likely make any device explode because of the lag it will create, which is why Roblox has an execution limit to prevent crashes. Here’s my feedback:
To put it plain and simply, Touched can be unreliable. The Touched event can be fired multiple times at once. If you want to achieve an accurate result, I’d suggest using :ArePartsTouchingOthers().
The problem may be what @C4SDBt1vzwr1xO9soCL3 said, the server just overloads. You will have to optimize your place somehow.
I suggest making Touched events not on the parts, but on players (or the parts that have to collide).
Oh well, it’s not all at once, the hitbox approximately covers around 20 parts at a time, so that’s not the case here. However I appreciate you passing me an alternative method, question is if it’s good for performance, since I’d need to run it each frame.
As said, need to fire touched event (that is on hitbox) whenever a hitbox touched any of the 10k parts. At most hitbox can cover 100 parts, but usually 30.
The game doesn’t freeze that much, only the touched event is not responding when clearly a hitbox is touching and moving inside of a part for a few seconds