Script: Hitbox

The online source for Kelleher Bros. music, literature, and video game-themed social commentary.

  • Home
  • General
  • Guides
  • Reviews
  • News

Script: Hitbox

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

private void OnTriggerEnter(Collider other) { if (!isActive) return;

local hitbox = HitboxModule.new(swordPart, 25, owner) hitbox script

public void Deactivate() { isActive = false; }

function HitboxModule:OnHit(character, hitPart) -- override for custom logic (sound, vfx, etc.) print( Hit {character.Name} for {self.Damage} damage ) end local humanoid = hit

function HitboxModule.new(hitboxPart, damage, owner) local self = setmetatable({}, {__index = HitboxModule})

return HitboxModule

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); } } }

  • Newer
  • Older

thekelleherbros@gmail.com

Give Luke a tip on Ko-fi
Support on Patreon

Kelleher Bros. is made possible through the support of our generous patrons, as well as these shrewd corporate sponsors:

hitbox script
hitbox script
hitbox script
hitbox script

…And by readers like you!

Subscribe

Sign up with your email address to receive Kelleher Bros. news and updates.

We respect your privacy. Your information will not be shared with any third parties.

Thank you!
KelleherBros_Japan-style_emblem-SQUARE.png

© Kelleher Bros. 2014 - 2026

Copyright © 2026 Fast Digital Forum