hi, right now, im re inventing how my hitboxs works, i sully made them in Server, Being Cast In server.
but right now, i wanted to make attacks more faster, and animations load before hand, i made them in Server. now im changing to Client more,
ofc not making Client Handle Everything, but now i notice that Hitboxes Are more delay,
Because im Casting it On Server with RemoteEvents.
now should i change Hitbox System to Client?, or keep in Server?
If you’re dealing with melee box hitboxes, then you can simply allow the client to calculate which players they hit, and then on the server, for each hit player, find their distance from the client and if the distance is less than or equal to (length of box hit box + 3 studs) then you can safely assume that the player has been legally hit. We add 3 studs to account for latency between the players, 3 studs may be too much but that’s for you to find out. Granted you would need to ensure that the hitbox is a cube so each length is equal so that there won’t be any sort of discrepancy in the distance calculation.
You can do something similar to that if you’re dealing with guns/ranged detections by creating a cylinder with a 3 stud radius (again, experiment with the size of the radius), point it in the direction that the client is facing, and extrude it to the point where the bullet hit a surface (like a player or wall) and then additionally extrude by an extra stud or so. If the hit player is within the cylinder, they have been legally hit. In this scenario you would need to calculate where the bullet hit a surface from the server - we only use what the client has said they hit, not where.
The idea with these methods is to find out whether the players that the client has said that they hit is plausible or not. Obviously, if they hit someone illegitimately across the map with a melee or through a wall, the calculations would prove that those were illegitimate, but still being lenient enough to accept a degree of latency for hits that weren’t exactly within the scope of hitboxes.
This is a good start. Also, as a rule of thumb, leave initial hit detection to client and then validate on server. Especially on roblox, this seems to always end up working better and being more playable.
Client to server is helpful because the server can only worry about a hit if a client thinks they got one. As stated you can send the clients request to the sever for verification and handling actual damage.
It’s common that the client side does play some effect initially when they think they got a hit while they send it to the server who can accept or reject, and the server may send a confirmation back to the client which may play another affect that shows it was accepted or it can ignore it or whatever you want with style. The client effect playback considerations is to balance it feeling responsive, with it being accurate.
Like what the others are saying, a mix of client and server goes a long way!
IMO, user experience is a big factor when it comes to these games, and you’d want to prioritize that. Hence why I root for detecting hitboxes on the client.
Aaaand about the risk of cheating, I mean honestly, just validate it decently enough. For the ones that still bypass, let systems like votekicking handle that for ya!
yall comments are great, i can just pack it up, and do it, but i have a small problem, im a bit insucure about how i cast the hitboxes.
so what i mean is that, like i said im moving everything in client, to a better feel.
local function FSM()
local Argument
if not folder then
warn("Not Finded Fun Folder")
return
end
local AbilityFolder = folder:WaitForChild("Spec")
if not AbilityFolder then
warn("Not Finded Ability Folder")
return
end
local ScriptsFolders = AbilityFolder:WaitForChild("Scripts")
if not ScriptsFolders then
warn("Not Finded Scripts Folder")
return
end
local remote: RemoteEvent = ScriptsFolders:WaitForChild("Scripts"):FindFirstChildOfClass("Script"):FindFirstChildOfClass("RemoteEvent")
task.spawn(function()
for ind, val in pairs(spec) do
if speccode.Value == ind then
Argument = val
end
end
end)
if not Action then
warn("Not Set action String")
return
end
remote:FireClient(player, {ActionAttack = Action}, Argument)
end
this is how im casting the Attack, and if you did notice, im doing a FireClient.
wich means Fires only one client (the attacker)
now the problem bc is being send to one client, and i make the knockback or vfxs (not damage, cuz is obvius that would be on Server), will be see to others?, or even how i cast the Vfxs or Knockback Faster, without using Remote Events, and just generaly Faster.