Hitbox Script Guide
return self end
return HitboxModule
function HitboxModule.new(hitboxPart, damage, owner) local self = setmetatable({}, {__index = HitboxModule}) hitbox script
local humanoid = hit.Parent:FindFirstChild("Humanoid") local character = hit.Parent if not humanoid then -- check if hit is a limb inside a character local limb = hit if limb.Parent and limb.Parent:FindFirstChild("Humanoid") then humanoid = limb.Parent.Humanoid character = limb.Parent end end if humanoid and character ~= self.Owner then if not self.HitCharacters[character] then self.HitCharacters[character] = true humanoid:TakeDamage(self.Damage) -- optional: trigger hit effect self:OnHit(character, hit) end end end) end owner) local self = setmetatable({}
self.Part = hitboxPart self.Damage = damage or 10 self.Owner = owner self.Active = false self.HitCharacters = {} -- track already hit characters hitbox script
