Rays completely ignoring a part, but only when not running in Studio

The issue is seemingly impossible to debug.

During a testing session two weeks ago, hitboxes performed perfectly and we were able to play for over two hours with no issues whatsoever. Fast forward a week and during the next testing session hitboxes are completely broken as nobody can get hit. I decide to roll back to previous weeks version just to have some fun as it’s an issue that needs fixing before the game is playable at all. However, the exact same issue is happening even though that version worked? I use source control software while working on the game, so no change goes unnoticed. I also tried rolling back through the Roblox website but that resulted in the same issues.

No errors emerge from the code, which means it must be an issue in the logic itself. When raycasting to detect what weapons have hit, before each cast on the server hitboxes are cframed to every characters position rolled back in time up to 1000ms to compensate for the shooters ping.

Now here is the confusing part:

  1. Upon further inspection the hits seemed function sometimes, but it it’s roughly once per 200 casts or more.

  2. Hitboxes function perfectly while testing in Studio, i.e. running multiple game instances. Here is a screenshot of what it looks like and as you can see both the client and server hit the exact same point. I moved after shooting just so the ray path is clearly visible

  3. When playing in a published version of the game, through Roblox, the issue is present and here is what it looks like. If you zoom in on the screenshot you will notice that the server ray completely passed through the hitbox as if it didn’t exist at all and ended up hitting the ore node behind the hitbox.

  4. I already performed checks to make sure the ray blacklist isn’t ignoring the hitboxes completely, which it is not. The only instances present in that table are the player characters(don’t need characters to get hit as they will conflict with hitboxes). The hitboxes are parented to a completely separate folder in the workspace, they are not connected to characters in any way.

  5. I narrowed down all of my code and debugged every single step involved in raycasting and hitboxes. All of the variables should be correct and nothing unexpected is passed to the workspace:Raycast method. It just decides to act as if these hitboxes do not exist, while they are definitely present in the workspace.

I have no idea what is causing this issue to happen while playing in live builds of the game and I suspect it might have something to do with the Roblox Engine itself, however I have no proof for that so I am going to assume my code is at fault.

Any suggestions, ideas or thoughts on how I could proceed fixing this issue would be great as it’s significantly delaying further development on the game!

The code of the class handling hitboxes and raycasting is located at this pastebin: I have temporarily removed this code due to it not being relevant anymore. If code is needed feel free to contact me directly.

I have spent multiple days trying to come up with a reason and/or fix after posting this thread.

However, all efforts proved futile. No matter how much I debugged the behavior it simply acted in a different manner than it should of. I took a week off from development due to unrelated reasons.

Fast forward to today, I go ahead and test the hitbox behavior again, and seemingly out of nowhere it’s completely functional once again without any additional changes whatsoever.

This leaves me 99% sure that it must of been the Roblox Engine’s fault and not in my code. I haven’t been able to notice any fixes to related to raycasting, but there have been some changes/improvements to the code handling raycasting.

Hopefully this issue does not show up again and the game continues running as it should.