Help With Getting Touching Parts Within A Specific Time Frame

Hello, I am having troubles with my Combat System. I am trying to Query or Detect Players When The Sword Swings but the problem is that I’m struggling with the hitbox detecting the actual enemy. I want to query or get all the parts in the hitbox during the entire duration of the swing but using while loops, waits, and task.wait() completetly breaks this script and allows the player to swing multiple times, when the original script works perfectly with the cooldown.

if (tick() - PlayerStates[player.Name].LastM1) > 0.6 then

local HitBox = player.Character:FindFirstChild(ArisenProfiles[player].EquippedItem):FindFirstChild("HitBox")
local SwingAnimation = player.Character:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator"):LoadAnimation(game.ServerStorage.WeaponAnimations:FindFirstChild(ArisenProfiles[player].EquippedItem).Swing1R)

HitBox.Color =, 0, 0.0156863)

-- Add Solution Code Here

HitBox.Color =, 1, 1)

PlayerStates[player.Name].LastM1 = tick()

If anybody can share a solution to this problem without using raycasts, and using the hitbox system would be greatly appericated.


Try workspace:GetPartBoundsInBox()? It detects every parts, even yours or the enemy’s, as long as it’s in the radius. It may has many parts of the same parent or ascendant so you’ll have to do something about it. You can also use OverlapParams to specifcally blacklist or whitelist instances and its descendants.

I use a system just like this for animations and hitbox sync, minus the actual hitbox detection method.

What you want to do is use AnimationEvents

and for every attack animation throw in an event to start the hitbox, using the same name for every animation’s event.

You the connect the event to a function in your script, which initiates the hitbox.

If you want it to end before the animation ends, you could use another AnimationEvent to tell the script when to stop.

Examples being “HitboxStart” and “HitboxEnd” as animation events for your attack animations.

1 Like