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:
-
Upon further inspection the hits seemed function sometimes, but it it’s roughly once per 200 casts or more.
-
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
-
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.
-
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.
-
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.