How do I make this client-side melee hit box more secure?

Do you know how to fix this bug? I feel like doing Mouse1Button on the local script will do nothing about this

https://gyazo.com/04b1c6e58fa2d580d9fb2b3634cdaeb0

How would it not fix it? The MouseButton1Click function is designed to detect when the LeftButton on the mouse is clicked.

Yeah but how come I can fire remote events without attacking, it shows it the GIF

Im using a remote fire script to fire my own remote events and the MouseButton1Click is not preventing that

So it’s just attacking people whenever you get near them? Are you doing anything to the code to try and make this happen?

No, im firing my own remotes on my command

And the mouse1button is not preventing that from happening

So you’re just walking up to them and they’re all taking damage?

Why aren’t you creating the hitbox on the sever?

Add debris to Serverscript. This is because exploiters can change its time and possibly the instance. Its always good practise to add debris in Serverscript. Even the smallest thing will tighten security.

I think its literally impossible to stop an exploiter from executing a remote event on their client. Exploiters have COMPLETE control over anything client side. If you are making the hitbox on the client, exploiters can literally input anything into the parameters of the remote event.

The best you can do is a bunch of sanity checks ON THE SERVER to make the hits are legit, such as Magnitude, Angle checks using dot product, raycasting to see if there is a wall between the attacker and person getting attacked, and a Debris cooldown on the server. There is probably more sanity checks you could do depending on what you want to achieve.

You could also make the hitbox on the server, BUT this results in delayed hitboxes (depending on player’s ping ms) due to the player having to send a input through a remote event and then it has to reach the server. If this isn’t a problem for your game you could make the hitboxes on the server and it would be completely secure.

1 Like

To detect when mouse is clicked in client, do this:

local mouse = plr:GetMouse()
local clicked

mouse.Button1Down:Connect(function()
clicked = true
if clicked == true then
-- code here when they click\attack the player
end)

mouse.Button1Up:Connect(function()
clicked = false
end)

Because I have a timestop script and if I do that, then it wont detect because I anchored all players on the server but locally unanchored myself