local HitboxModule = require(script.Parent.HitboxModule) local swordPart = script.Parent local owner = script.Parent.Parent.Parent -- assume character
function HitboxModule:OnHit(character, hitPart) -- override for custom logic (sound, vfx, etc.) print( Hit {character.Name} for {self.Damage} damage ) end hitbox script
local hitbox = HitboxModule.new(swordPart, 25, owner) local HitboxModule = require(script
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
Here’s a clean, modular suitable for a game (like Roblox Luau, Unity C#, or general pseudocode).
function HitboxModule:Deactivate() self.Active = false if self.Connection then self.Connection:Disconnect() self.Connection = nil end end