So I made a script on the client that checks the hitbox with spatial query when the player is trying to hit someone. I made everything on server side but I want to make the hitbox on the client to prevent delay. To prevent hackers from just hitting everyone in the game I am trying to check wether they are in a decent distance from the target or not. (Im passing player and hitContent on the remote event).
Is there a more optimal way to make something like this.
local function hitBoxCheck(player, hitContent)
local Ahrp = player.Character:FindFirstChild("HumanoidRootPart")
for _, humanoid in hitContent do
local Vhrp = humanoid.Parent:FindFirstChild("HumanoidRootPart")
if (Ahrp.Position - Vhrp.Position).Magnitude <= 50 then
damage(player,humanoid.Parent,4)
end
end
end
Im not sure if it will be faster, but remote functions allow you to return to the client. You can have it check distance and return the result to the client. You may be able to mess with them.
but that would be pretty exploitable. what im doing is im taking the hitbox on the client, passing it to the server and then check if the hit targets are at a reasonable distance(only if the debounce is false). Im asking if there is a better way to do that
Itd act the same way since the server would validate it. All exploits can really do is fire it or change a value client side, the same way you fire that remote event its just that it allows for a value to be sent back. So, you can have it do the bare bones while sending some stuff back. Player characters also sync instances across server and client I believe, allowing the server to see whats been deleted in a character. However, I havent used that in a while