I know there are tutorials on youtube, and the forum on how to make a effective hitbox system for a combat system, however I don’t really understand them. I’ve tried making a combat system before, however I always ran into a problem with the hitbox being really buggy, and not accurate to the two client’s screens.
The system I used was simple - I detected a M1, then used a Hitbox module that used GetPartsInParts(), and gave all the enemies to the server, that then dealt damage to the enemies in the table given by the client.
Does anyone have a good way of making a proper hitbox system, and can explain it to me, on how it works, and how it’s smoother than my way, or just better in general?
Okay, first of all why are you trusting the client to handle giving the players to the server…?
An exploiter would abuse this vulnerability by just firing a table with players they want
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Vulnerable_Remote = ReplicatedStorage.VulnExample
RunService.RenderStepped:Connect(function()
local Arguments = {}
for _, player in ipairs(Players:GetPlayers()) do
if player ~= LocalPlayer then
table.insert(Arguments, player)
end
end
Vulnerable_Remote:FireServer(Arguments)
end)
Instead, just fire a remote named however you want (with no arguments being passed through), and when its detected by the server, let the server handle the hitbox system.
And when the server gets the signal, you could either use these type of hitbox systems for the server:
Options:
1.) Get all players which has a root (or any object) in them in a table, and then get the distance of them between the client’s root (or any object) from the players inside the table. Set your maximum distance and deal damage to those players inside the client’s range of attack.
2.) Let the server handle getpartsinpart() when the M1 event is detected by the server.
3.) Still use your hitbox system, but handle sanity checks for the server (An example of this is checking the distance between each player fired in a table to prevent exploiters from abusing the vulnerability)
Although it might seem innacurate, it’s just a problem on lag or on roblox’s side.
Here’s a clip from a youtube video which shows a great example of this:
(Credits to Coobs, I suggest you watch his video about it to get a clearer understanding. It’s a really great vid btw haha)
No, not really. Since the hitbox function in the server script would just activate every time the remote is fired. But if there’s no server script accepting the fired signals, yes it would lag. But not the server, only the client that fired it would lag.
TL;DR: No, the server can handle hitbox calculations without any issues/lag.