I have a hitbox system and my newly made barrage ability(It looks goofy I know). Anyway for some reason, once I enter the hitbox, event if I go out it will continue to hit me. At first I thought the issue was that the detection code would only run once then the loop would continue using the objects detected but that is not the case, the loop redetects new Intakehitboxes(the red ones) every time it runs so it should not be damaging the player. Here is the code that is ran when the attack begins and its purpose is to find any “IntakeHitBoxes” within the attacks hitbox(the green one) and send values about the specific attack to the IntakeScript within all IntakeHitboxes :
if action == "Barrage" then
stopBigAttack = false
stopBarrage = false
if detectors.CanBarrage.Value and detectors.WeaponEquipped.Value and cooldowns.Barrage.Value == false then
StopTracks()
Barrage:Play()
detectors.IsBarraging.Value = true
detectors.CanDash.Value = false
detectors.CanBlock.Value = false
detectors.CanAttack.Value = false
detectors.CanEquip.Value = false
detectors.CanDeflect.Value = false
humanoid.WalkSpeed = 4
humanoid.JumpPower = 0
local repitions = 0
local hitbox = character.HitBoxes.BasicM1Box
local IntakeHitbox = character.HitBoxes.IntakeHitBox
local params = OverlapParams.new()
params:AddToFilter(IntakeHitbox)
while true do
task.wait(0.1)
if stopBigAttack or stopBarrage or repitions == 50 then
Barrage:Stop()
stopBarrage = false
break
end
repitions += 1
local parts = game.Workspace:GetPartsInPart(hitbox,params) do
for i,part in pairs(parts) do
if part.Name == "IntakeHitBox" then
local newChar = part.Parent.Parent
local IntakeScript = require(part.IntakeScriptModule)
IntakeScript.DamageAmount = 0.8
IntakeScript.KnockbackPower = 1
IntakeScript.UpKnockback = 0
IntakeScript.PlayerWhoHit = character
IntakeScript.Ragdoll = false
IntakeScript.RagdollTime = 0
IntakeScript.BlockBreaks = false
IntakeScript.CanParry = false
IntakeScript.BlockAdditions = 100
IntakeScript.Iframes = 0
IntakeScript.StunType = true
IntakeScript.StunTime = 300
IntakeScript.OnlyOneCanHit = true
IntakeScript.OnlyOneTime = 300
IntakeScript.ReceiveDamage()
end
end
end
end
detectors.IsBarraging.Value = false
cooldownTimers.Barrage.Value = 15000
MovementControl.WalkSpeed.Value = 50
MovementControl.JumpPower.Value = 50
detectorTimers.CanDash.Value = 50
detectorTimers.CanAttack.Value = 50
detectorTimers.CanEquip.Value = 50
detectorTimers.CanBlock.Value = 50
detectorTimers.CanDeflect.Value = 50
end
end
Don’t worry about the rest of the code, the only important part is when I use :GetPartsInPart.
Getting Hit outside of hitbox - Clipped with Medal.tv is a video showing the issue