Kult's Hitbox System [Use for Combat Hitboxes]

Hey developers, I’ve had made a Hitbox from scratch to myself thinking that It’d be nice to share it with all of you guys who needs it as well. I’ve made it easily “Customizable” and with an built in “Anti - Cheat” already and easy to read. Below it’s just me explaining on how to set it up/how it works.

Now I’m going to show you how the settings works, currently these are the only settings that I have right now.

Hitbox.Settings = {
	Damage = 10;
	Size = Vector3.new(5,5,5);
	DebrisTime = .75;
	Offset = CFrame.new(0,0,-2.5);
	DebounceTime = 1;
}
  1. So now I’ll explain on what all of them does. So firstly we have “Damage” as you know, it’s just to adjust how much damage you want to do on the players.

  2. Then we have “Size”, this is for adjusting the size for the hitbox meaning if you set it for 10, it’ll have a bigger hitbox radius.

  3. Now we got “DebrisTime”, This is for how long you want the hitbox to appear, after the time is up, the Hitbox would delete itself.

  4. Then we have the “Offset”, this is used to help with the offset of the hitbox, meaning if you need the hitbox to the right, you’d make the offset to the right and so on.

  5. Lastly, we have “DebounceTime”, this is for how long you want to wait after you spawned in a hitbox, meaning if you had it for “5” seconds, you’ll need to wait 5 seconds so that you can be able to spawn another hitbox.

Now, I’ll show you on how to use it. Firstly you need to download the [Module] that I’ll link down below, and then you’ll have to place the stuff in the correct locations, which is shown right now.

**Place “HitBoxSettings” and “HitPart” inside of “ReplicatedStorage”.
image

Place “HitboxDamage” inside of “ServerScriptService”.
image

Now, place “CD” and “UserInput” Inside of “StarterChracterScripts”, lastly place “Hitboxes” in the workspace to keep things clean.

image
image

Now, that you got everything set up right, we’ll show you how to use it inside the script. First off, you need to require the module first and then use the function from it, just like this.

local HitboxSettings = require(game.ReplicatedStorage:WaitForChild("HitBoxSettings"))
HitboxSettings:CreateHitbox(plr)

You need to send a “Player” bool to the parameter otherwise it won’t work, then to use the “DebounceTime”, it’s the same thing but just need to change it up a bit so like so. It goes the same with “Damage”.

task.wait(HitboxSettings.Settings["DebounceTime"])
:FindFirstChildOfClass("Humanoid"):TakeDamage(HitboxSettings.Settings["Damage"])

So now I’m just going to explain how this Hitbox works, so for the detection I’m using is “OverlapParams” which is great to use for Hitboxes like this, I’ve have tried my best to make it not lag when detecting BaseParts, so it shouldn’t make your performance feel worse when using it.

Below here is where you can add in a Blacklist/MaxParts, to improve the hitbox detection, The information for what they do is already listed inside the script.

local Params = OverlapParams.new()
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	Params.FilterDescendantsInstances = {plr.Character, Part} -- Insert stuff here if you want to blacklist them for being detected.
	Params.MaxParts = 50 -- How many items to be detected before it stops detecting.

Here’s the main detection, I’ve made it only detect the “BaseParts” for “performance”, as well used a table method to help blacklist the Humanoid that’s already has been damaged. Then at the end, when the Hitbox gets destroyed, the RenderStepped will be disconnected to prevent Memory leaks.

	--[Main Humanoid Detection]--
	
	RenderStepped = game:GetService("RunService").RenderStepped:Connect(function()
		local HitTable = game.Workspace:GetPartsInPart(Part, Params)
		for i,v in ipairs(HitTable) do
			if v:IsA("BasePart") then
				local Humanoid = v.Parent:FindFirstChildWhichIsA("Humanoid")
				if Humanoid ~= nil then
					if not table.find(HumTable, Humanoid) then
						table.insert(HumTable, Humanoid)
						self.Remote:FireServer(Humanoid.Parent)
					end
				end
			else
				return
			end
		end
	end)
	--[Close the RenderStepped for Memory]--
	
	task.spawn(function()
		Part.Destroying:Connect(function()
			RenderStepped:Disconnect()
		end)
	end)

Then here we have the “Anti - Cheat” that I have made to prevent “Spamming Hitboxes” and such. Below it’ll show how it works, It’ll first make a “BoolValue” on the server and it’ll parent into the Character’s “CD”, Then it’ll check if there’s any existing BoolValue or if there’s none, which leads into a Kick, since it only accepts with 1 BoolValue, It can’t have more than 1 BoolValue or less. So then if it’s 1 then it’ll finally damage the Humanoid.

if anticheat == "AntiCheat" then
		local Bool = Instance.new("BoolValue", plr.Character:WaitForChild("CD"))
		game.Debris:AddItem(Bool, HitboxSettings.Settings.DebounceTime / 1.25)
	end
	task.spawn(function()
		local CooldownChildrens = plr.Character:WaitForChild("CD"):GetChildren()
		
		if not plr.Character:WaitForChild("CD"):FindFirstChildOfClass("BoolValue") or #CooldownChildrens > 1 then
			return plr:Kick("Kicked for trying to spam Hitboxes.")
		end
	end)
	
	if plr.Character:WaitForChild("CD"):FindFirstChildOfClass("BoolValue") then
		if hum then
			print('Damaged.')
			hum:FindFirstChildOfClass("Humanoid"):TakeDamage(HitboxSettings.Settings["Damage"])
		end
	end

That’s all of it now. For notice, this Hitbox is good to use for large / Slow Moving Objects. Otherwise, if you’re looking for a small Hitbox, it’s best to use RayCastParams, I’ll probably make one for it but not soon. Any feedback on this would help a lot, As I’m trying to get the best performance and as well easy to customize for you guys. Anyways, hope you enjoyed my tutorial as well my hitbox system! :smiley:

11 Likes

looks and works nice but is there a way to change the setting for scripts individual so for different scripts it has different damage or size etc.

What is preventing exploiters from doing this?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer
local hitboxRemote = ReplicatedStorage:WaitForChild("HitBoxSettings").HitboxRemote
local hitboxSettings = require(ReplicatedStorage:WaitForChild("HitBoxSettings"))

local DEBOUNCE_TIME = (hitboxSettings.Settings.DebounceTime)

while true do
	for _, v in pairs(Players:GetChildren()) do
		local plrChar = v.Character or v.CharacterAdded:Wait()
		hitboxRemote:FireServer(plrChar, "AntiCheat")
	end
	
	task.wait(DEBOUNCE_TIME)
end

If you setup the hitbox in a new place and run the above code using the command bar, you will see that it will infinitely damage every player in the server while still being under the rate limit.

I recommend you add multiple checks on the server such as magnitude checks and other sanity checks in order to prevent people from exploiting it easily.

3 Likes

Alright I’ll update it for that, hold on.

1 Like

So basically every hitbox that been fired, it will add in a “boolvalue” such as a cooldown and then it’ll check if it has more than 2 bool value or 0, if so it’ll kick them but if not then it’ll damage them

You’re gonna have to either get a new model of mine because I will update it.

Hey guys!, I updated the settings for multiple uses purposes as well added more stuff in the settings. So I’ve made the settings to work when you’re trying to change the settings at some point in your hitbox, so basically I moved the settings to you, so you gonna have to insert the settings. Here’s is an example of it.

Settings1 = {
	Damage = 10;
	Size = Vector3.new(5,5,5);
	DebrisTime = .75;
	Cooldown = 1.5;
	Offset = CFrame.new(0,0,-2.5);
	MaxParts = 50;
	Blacklist = {plr.Character}
}

As usual we have the same stuff but we have 2 new things, which is “MaxParts” and “Blacklist”, So first with MaxParts, what it does is, it limits the detection to how many parts it detects before it stops detecting, pretty simple. Then we got “Blacklist”, this for when you want to blacklist a BasePart or something on your workspace to prevent it from being detected by the hitbox.

Now, I did change it up a bit now so here’s how you’re going to use it. You just want to insert all of the settings that you made inside the correct parameters. It needs to be in a specific order otherwise it won’t work.

HitboxSettings:CreateHitbox(plr, Settings1.Damage, Settings1.Size, Settings1.DebrisTime, Settings1.Cooldown, Settings1.Offset, Settings1.MaxParts, Settings1.Blacklist)

Anyways, good luck with it as well send feedback to me or any bugs! :+1: :smile:

If you guys want to try out the hitbox, you can join this game and use “E” on your keyboard and it’ll spawn in a hitbox for you. I also added dummys for you to kill.

Test out the code from my previous post, it does not kick you out since it fires immediately after the cooldown has ended.

So what are you trying to do in the script, fire the hitbox for everyone and wait after the cooldown?

So basically it loops through every player in the game, fires the hitbox remote with the player’s character the as argument and waits until the cooldown ends and it repeats it infinitely.

image
It kicked me?

Did you use the code I posted above?

Just tried spamming this but it doesn’t spams but instead has the normal cooldown

local plr = game.Players.LocalPlayer
local HitboxSettings = require(game.ReplicatedStorage:WaitForChild("HitBoxSettings"))

Settings1 = {
	Damage = 10;
	Size = Vector3.new(5,5,5);
	DebrisTime = .75;
	Cooldown = 1.5;
	Offset = CFrame.new(0,0,-2.5);
	MaxParts = 50;
	Blacklist = {plr.Character}
}

HitboxSettings:CreateHitbox(plr, Settings1.Damage, Settings1.Size, Settings1.DebrisTime, Settings1.Cooldown, Settings1.Offset, Settings1.MaxParts, Settings1.Blacklist)
  • I also did improve my anti cheat as you said with the magnitude checks.

There’s a new model, try using that one because the one u made wont work for it, try this script for the new one.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local hitboxSettings = require(ReplicatedStorage:WaitForChild("HitBoxSettings"))

while true do
	for _, v in pairs(Players:GetChildren()) do
		local plrChar = v.Character or v.CharacterAdded:Wait()
		hitboxSettings.AntiRemote:FireServer(plrChar)
	end

	task.wait(1)
end

Alright hold on, but I will be changing the task.wait(1) to the cooldown amount

yh just drop it again, and place everything where it belongs, I did added a separate remote for the anti cheat

Here’s a video of showing that it is working. The errors are from the cooldown which is set to “1”

Somehow this version got worse since you can pass in the damage and the cooldown. I modified the script a bit, here is the new one:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer
local hitboxRemote = ReplicatedStorage:WaitForChild("HitBoxSettings").DamageRemote
local antiCheatRemote = ReplicatedStorage:WaitForChild("HitBoxSettings").AntiCheat
local hitboxSettings = require(ReplicatedStorage:WaitForChild("HitBoxSettings"))

local DEBOUNCE_TIME = 0.5
local DAMAGE_TO_DEAL = math.huge

while true do
	for _, v in pairs(Players:GetChildren()) do
		local plrChar = v.Character or v.CharacterAdded:Wait()
		antiCheatRemote:FireServer(DEBOUNCE_TIME)
		hitboxRemote:FireServer(plrChar, DAMAGE_TO_DEAL)
	end

	task.wait(DEBOUNCE_TIME + 0.25)
end

You’re just not fully setting up the hitbox configuration, as it kicked me after I filled the configuration the right way. You just did the damage and nothing else.

image

Use this version, it’ll kick you.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer
local hitboxRemote = ReplicatedStorage:WaitForChild("HitBoxSettings").DamageRemote
local antiCheatRemote = ReplicatedStorage:WaitForChild("HitBoxSettings").AntiCheat
local hitboxSettings = require(ReplicatedStorage:WaitForChild("HitBoxSettings"))

local DEBOUNCE_TIME = 0.5
local DAMAGE_TO_DEAL = math.huge

Settings1 = {
	Damage = 10;
	Size = Vector3.new(5,5,5);
	DebrisTime = .75;
	Cooldown = 1.5;
	Offset = CFrame.new(0,0,-2.5);
	MaxParts = 50;
	Blacklist = {localPlayer.Character}
}

while true do
	for _, v in pairs(Players:GetChildren()) do
		local plrChar = v.Character or v.CharacterAdded:Wait()
		antiCheatRemote:FireServer(DEBOUNCE_TIME)
		hitboxSettings:CreateHitbox(localPlayer, Settings1.Damage, Settings1.Size, Settings1.DebrisTime, Settings1.Cooldown, Settings1.Offset, Settings1.MaxParts, Settings1.Blacklist)
	end

	task.wait(DEBOUNCE_TIME + 0.25)
end