I'm also open to any tips about the way I've formatted the script or just to do things a completely different way
local Debris = game:GetService("Debris")
local Hitbox = {}
Hitbox.__index = Hitbox
function Hitbox.Visualise(HCFrame : CFrame, Size : Vector3, Duration : number)
local Part = Instance.new("Part", workspace)
Debris:AddItem(Part, Duration)
Part.CFrame = HCFrame
Part.Size = Size
Part.Anchored = true
Part.CanCollide = false
Part.CanQuery = false
Part.CanTouch = false
Part.Color = Color3.new(1, 0, 0)
Part.Material = Enum.Material.ForceField
end
function Hitbox.New(HCFrame : CFrame, Size : Vector3, Owner)
local NewHitbox = {}
NewHitbox.HCFrame = HCFrame
NewHitbox.Size = Size
NewHitbox.Owner = Owner
setmetatable(NewHitbox, Hitbox)
Hitbox.Visualise(HCFrame, Size, 0.5)
return Hitbox
--print(Hitbox)
end
function Hitbox:Touching()
print(self.HCFrame, self.Size)
--[[local Hit = workspace:GetPartBoundsInBox(self.HCFrame, self.Size)
local HitCharacters = {}
for index, part in Hit do
if part.Parent:FindFirstChild("Humanoid") then
if part.Parent ~= self.Owner then
if not table.find(HitCharacters, part.Parent) then
table.insert(HitCharacters, part.Parent)
end
end
end
end
return HitCharacters]]
end
return Hitbox