Should I do RaycasthitboxV4 on the client or server

I want to create a fist combat system using the raycasthitboxV4 module, and I was wondering whether it would be better to:

  1. Fire server and create the hitbox there, I would also be damaging and knocking back the enemy player on hit there too
  2. Create the hitbox on the client, and on enemy player hit, fire server to damage and knockback the enemy

The main difference that I noted between the two is that the first method would make it so the player and enemy can see the enemy get hit at the same time, while the second method may let the player see the enemy get hit before the enemy sees themselves get hit.

I wanted to get some opinion on what would be better, thanks in advance.

Depends tbh, I would recommend doing it all on the client (hitboxes, raycasting, etc.), but damage on the server (and have some santiy checks such as the rate they are punching and the distance away they are). If this is a gamemode like 1v1, 2v2, you could take the server route as there won’t be a lot of traffic (unless its a fast pace game where you can punch really fast). I technically still recommend taking the client route as it will help the put less stress on the server.

1 Like

This method is a lot safer. I would suggest requesting characters cframe from the client or sending it as an argument so the hitboxes aren’t lagging behind that much, make sure to do the nan checks etc for both orientation and position.

1 Like

do the hitbox on the server. if you’re doing it on client anyone can easily exploit that

1 Like

Client performs checks of validation

→ Ignore if it does not pass any checks
→ send to Server if it passes for validation

Server recieves information

→ Validate what the client is giving the server
→ Ignore if it does not pass checks
→ Execute code if check passes through checks


This avoids any unessecary calls to the server by using both Client/Server for validation. Any exploits may be sent through to the server, but the server will be there to validate it, in which they will fail if done correctly.

If any checks fail on the client, it wont go to the server to validation, which will be the case 90% of the time when nothing useful happens that the server needs to be aware about, thus reducing the amount of things being sent to the server.

In terms of checking and the verification of client information, you are better off checking if something is hitting the hitbox on the client, moving to the server, validating said information by doing another check, then performing everything you need to do on there.

2 Likes

If I created the hitbox on the client, how would I validate the hitbox connected on the server as you mention? Since the hitbox is created on the client, the server won’t be able to access it, so would it be like distance checks or confirming that the enemy and player exist be the checks?

Yea it’s mostly gonna be a 1v1 scenario and it won’t be super fast paced, but if I read correctly you said that doing it on the server would make everything slower right? Because I’m trying to figure out how to make it smooth for both the player and enemy.

You’ll never get a perfect flawless experience due to different networking speeds, but for the most part a little delay is fine. If you run it from the server, it may be delayed for someone who has a high ping. Furthermore, having on the client will give a more fair fight due to it being dependent of the own client rather then the server which has replication latency already.

So the conclusion is that I should basically handle the hitbox and knockback on the client, and simply send the damage occured to the server while making sure it’s legit?

Yep, that is exactly what you should do.

You would create another one on the server. In which the Client will be used for the first validation check, and then the server will confirm what the client is returning, otherwise it will yield no result at all.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.