i made a new general hitbox system and it works completely fine other than it picking up the same entity in the same hitbox and that then multiplies the damage.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local CollectionService = game:GetService("CollectionService")
local Debris = game:GetService("Debris")
local module = {}
local function ConvertToVector(CF)
return typeof(CF) == "CFrame" and CF.Position or CF
end
module.Object = {
["CreateInstance"] = function(RequestedInstance, Properties)
local function CheckProperty(Object, Property)
local Property = Object[Property]
end
local Object = Instance.new(RequestedInstance)
for i, v in pairs(Properties) do
if pcall(function()CheckProperty(Object, i)end) then
Object[i] = v
end
end
return Object
end,
["GetPartsInBox"] = function(Part)
local Connection = Part.Touched:Connect(function() end)
local Results = Part:GetTouchingParts()
--Part:Destroy()
Connection:Disconnect();
Connection = nil;
return Results;
end,
}
module.Hitbox = {
["GetPartsInBoundBox"] = function(Player,HitboxData)
local Player = Player or game.Players.LocalPlayer
local Character = Player.Character
local Humanoid,Root = Character:FindFirstChild("Humanoid"), Character:FindFirstChild("HumanoidRootPart")
local Hitbox = game.ReplicatedStorage.Assets.General.Hitbox
Hitbox = Hitbox:Clone()
local Transparency
if Player.Settings.HitboxDisplay.Value == true then
Transparency = 0.6
else
Transparency = 1
end
Hitbox.Size = HitboxData.Size
Hitbox.Transparency = Transparency
Hitbox.Orientation = Hitbox.Orientation or HitboxData.Orientation
Hitbox.Parent = workspace.Effects
Hitbox.Color = Color3.new(1, 0, 0)
Hitbox.Material = Enum.Material.ForceField
Hitbox.CanCollide = false
Hitbox.CastShadow = false
local weld = module.Object.CreateInstance(
"Weld",{Part0 = HitboxData.RelativePart or Character.HumanoidRootPart,
Part1 = Hitbox,
C0 = HitboxData.Offset or CFrame.new(0,0,-4)})
weld.Parent = HitboxData.RelativePart or Character.HumanoidRootPart
Debris:AddItem(Hitbox,HitboxData.WaitTime or 0.45)
Debris:AddItem(weld,HitboxData.WaitTime or 0.45)
local Zone = module.Object.GetPartsInBox(Hitbox)
local IsHit, EntitieList = false, {}
for _,Hit in ipairs(Zone) do
if not Hit:IsDescendantOf(Character) and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") and IsHit == false then
local Victim = Hit.Parent
local EnemyHumanoid,EnemyRoot = Victim:FindFirstChild("Humanoid"), Victim:FindFirstChild("HumanoidRootPart")
EnemyRoot.CFrame = CFrame.lookAt(EnemyRoot.Position,Root.Position)
if Victim ~= Character and EnemyHumanoid.Health > 0 and not table.find(EntitieList,Victim) then
if CollectionService:HasTag(Victim,"Hitable") then
table.insert(EntitieList,Victim)
print(Victim.Name)
IsHit = true
break
end
end
end
end
return IsHit,EntitieList
end,
}
return module