Hey i am working working on a barrage but for some reason after the Barrage the player cant take damage for a few seconds
coroutine.wrap(function()
while BarrageHandler.active == true do
local HRP = Character:WaitForChild("HumanoidRootPart")
local hitbox = script:WaitForChild("Hitbox"):Clone()
hitbox.Parent = Character
hitbox.CFrame = HRP.CFrame * CFrame.new(0,0,-2)
debris:AddItem(hitbox,0.1)
hitbox.Touched:Connect(function(hit)
if hit:IsA("BasePart") or hit:IsA("Model") then
if hit.Parent ~= Character then
if hit.Parent:FindFirstChild("Barrage") then
local eHum = hit.Parent:FindFirstChild("Humanoid")
local eHumRP = hit.Parent:FindFirstChild("HumanoidRootPart")
if eHum and eHumRP then
if eHumRP.Parent:FindFirstChild("lolyes") then return end
local eneH = hit.Parent.Humanoid
local hitE = {}
local found
for _, character in next, hitE do
if character == eneH then
-- some boolean toggle for match
found = true
end
end
if not found then
table.insert(hitE, eneH)
local bv = Instance.new("BodyVelocity",eHumRP)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = HRP.CFrame.lookVector*2.5
debris:AddItem(bv,.1)
local ring = script.Ring:Clone()
ring.Parent = workspace
ring.CFrame = HRP.CFrame * CFrame.new(0,0,-1)
ring.Orientation = ring.Orientation + Vector3.new(math.random(-180,180),math.random(-180,180),math.random(-180,180))
tweenservice:Create(ring,TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut),{Size = ring.Size + Vector3.new(25,0,25),Transparency = 1}):Play()
game.Debris:AddItem(ring,.5)
game.ReplicatedStorage.BarrageFXDamage:FireServer(eneH,damage-.25)
hitbox:Destroy()
local indicators = game.ReplicatedStorage:FindFirstChild("DmgIndicators")
if indicators then
local gui = indicators:Clone()
gui.Parent = hit.Parent.Head
local text = gui.Damage
text.Text = tostring(damage-.25)
gui.StudsOffset = Vector3.new(math.random(-2,2),1,math.random(-2,2))
game.TweenService:Create(gui, TweenInfo.new(.7,Enum.EasingStyle.Sine,Enum.EasingDirection.Out), {StudsOffset = gui.StudsOffset + Vector3.new(0,2,0)}):Play()
game.TweenService:Create(text, TweenInfo.new(.7,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut), {TextTransparency = 1,TextStrokeTransparency = 1,Rotation = math.random(-25,25)}):Play()
debris:AddItem(gui,1.3)
end
local sound = script:WaitForChild("GetHit"):Clone()
sound.Parent = hit.Parent.Torso
sound:Play()
debris:AddItem(sound,1)
wait(.1)
for i, character in next, hitE do
if character == eneH then
table.remove(hitE, i)
end
end
end
end
elseif hit.Parent:FindFirstChild("TSDamage") then
elseif not hit.Parent:FindFirstChild("Barrage") and not hit.Parent:FindFirstChild("TSDamage") then
local eHum = hit.Parent:FindFirstChild("Humanoid")
local eHumRP = hit.Parent:FindFirstChild("HumanoidRootPart")
if eHum and eHumRP then
if hit.Parent:FindFirstChild("lolyes") then return end
local eneH = hit.Parent.Humanoid
local hitE = {}
local found
for _, character in next, hitE do
if character == eneH then
-- some boolean toggle for match
found = true
end
end
if not found then
table.insert(hitE, eneH)
local bv = Instance.new("BodyVelocity",eHumRP)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = HRP.CFrame.lookVector*2.5
debris:AddItem(bv,.2)
game.ReplicatedStorage.BarrageFXDamage:FireServer(eneH,damage)
hitbox:Destroy()
local randomAnim = math.random(1,2)
if randomAnim == 1 then
eHum:LoadAnimation(script:WaitForChild("Hit1")):Play()
elseif randomAnim == 2 then
eHum:LoadAnimation(script:WaitForChild("Hit2")):Play()
end
local indicators = game.ReplicatedStorage:FindFirstChild("DmgIndicators")
if indicators then
local gui = indicators:Clone()
gui.Parent = hit.Parent.Head
local text = gui.Damage
text.Text = tostring(damage)
gui.StudsOffset = Vector3.new(math.random(-2,2),1,math.random(-2,2))
game.TweenService:Create(gui, TweenInfo.new(.7,Enum.EasingStyle.Sine,Enum.EasingDirection.Out), {StudsOffset = gui.StudsOffset + Vector3.new(0,2,0)}):Play()
game.TweenService:Create(text, TweenInfo.new(.7,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut), {TextTransparency = 1,TextStrokeTransparency = 1,Rotation = math.random(-25,25)}):Play()
debris:AddItem(gui,1.3)
end
local sound = script:WaitForChild("GetHit"):Clone()
sound.Parent = hit.Parent.Torso
sound:Play()
debris:AddItem(sound,1)
Hiteffect3(hit.Parent.HumanoidRootPart)
wait(.1)
for i, character in next, hitE do
if character == eneH then
table.remove(hitE, i)
end
end
end
end
end
end
end
end)
wait(.102)
end
end)()