Constant car wheel size changing leading to HumRootPart .Touched() spam firing issue

hi all! as much as i want to be very descriptive for clarity, i don’t want to be too specific as to what exactly i’m doing (for confidentiality), so i’ll describe everything as vaguely as i can while also being comprehensible (this is to hopefully explain any possible writing oddities and whatnot beforehand)

so basically, i’ve recently been working on a system that as its main purpose changes the size of a car’s wheels every frame on the client as long as a certain condition is met, this works perfectly fine and i have no issues with it.

however, the problem comes when the wheel size changing happens at the same time as a (client) touched event linked to the driver’s HumanoidRootPart is supposed to fire (once), when these two coincide, the event will instead fire every frame where the wheel size has changed and the player remains inside the part (size only changes while in motion), the big issue is that this Touched event adds to a leaderstat every time that it fires, so its functionality is basically ruined by the touch spamming - my question comes into play here: what could i do to potentially fix / find a workaround for this? so far i’ve only been able to think of running a spatial query every frame and replicating the functionality manually with more checks to prevent this from happening, but i don’t even know which one i’d use or even how i’d go about basically recreating the behavior using the new method, i don’t think theres much more i can mention regarding the issue without repeating myself or not providing anything of value

many thanks in advance to anyone who tries to help, i’m willing to answer questions the best i can if my crappy explanation wasn’t good enough !

So as I understood there’s a wheel that changes size.
The requirements:

  • register events when wheel touches player
  • minimize client - server communication

I would suggest:

  • keep a table of registered touches {[wheel_size] : boolean} on server side
  • query the table from client on game start and store it locally
  • when wheel touches by player check local table if it’s not reported yet
  • send event to server and store the touch in local table if event not reported
  • server validates the event against own table and updates score board

Instead of handling touches it’s probably better getting parts in wheels bounds in RunService.Heartbeat handler or every second in spawned thread because Touched spams a lot.

This sounds like a simple debounce fix..