Hitbox Script Link -

return self end

function HitboxModule:Activate() self.Active = true self.HitCharacters = {} self.Connection = self.Part.Touched:Connect(function(hit) if not self.Active then return end hitbox script

local HitboxModule = require(script.Parent.HitboxModule) local swordPart = script.Parent local owner = script.Parent.Parent.Parent -- assume character return self end function HitboxModule:Activate() self

-- when swinging hitbox:Activate() task.wait(0.3) -- swing duration hitbox:Deactivate() public class Hitbox : MonoBehaviour { public float damage = 10f; public GameObject owner; private bool isActive = false; private HashSet<GameObject> hitTargets = new HashSet<GameObject>(); public void Activate() { isActive = true; hitTargets.Clear(); } public GameObject owner

Health targetHealth = other.GetComponentInParent<Health>(); if (targetHealth != null && other.gameObject != owner) { if (!hitTargets.Contains(targetHealth.gameObject)) { hitTargets.Add(targetHealth.gameObject); targetHealth.TakeDamage(damage); OnHit(targetHealth.gameObject); } } }

Here’s a clean, modular suitable for a game (like Roblox Luau, Unity C#, or general pseudocode).