All touched events stop randomly working?

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().

1 Like

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).

2 Likes

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.

Also forgot to add, there’s only 1 touched event, which is on hitbox. The 10k parts have CanTouch on tho.

All events are done on client, and there is only one (hitbox), sorry forgot to add it to the post.

This is not unreliable, and now you will overload server even more because you will loop through 10k parts to run a line of code.

1 Like

Then how exactly do they work? What do they need to detect?

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.

I don’t see any problems with that then. Maybe it is the amount of parts freezing the game, not the scripting.

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

I mean that the events themselves freeze.

1 Like