Hi everyone so what I am trying to do is I Don’t want some player to get barrged twice in a row in a short time so I Put them in a table called “BStunned” until 0.7s pass but somehow i messed up the code and dont know how to make it work again please help this is the code:
local TweenService = game:GetService(“TweenService”)
local Debris = game:GetService(“Debris”)
local Barrage_Handler =
{
isactive = false;
damage = .5;
}
local DictionaryHandler = require(script.Parent.Parent.Library.DictionaryHandler)
function Barrage_Handler.punches(Character,Stand,Folder)
Barrage_Handler.isactive = true
while Barrage_Handler.isactive == true do
local pivotCFrame = Stand.PrimaryPart.CFrame * CFrame.new(0,.5,-6)
–primary parts
local leftLA = Stand:WaitForChild(“LeftLowerArm”):Clone()
for _, obj in pairs(leftLA:GetChildren()) do
if not obj:isA(“BasePart”) and not obj:isA(“ManualWeld”) then
obj:Destroy()
end
end
leftLA.CanCollide = false
leftLA.Anchored = true
leftLA.Parent = Folder
Debris:AddItem(leftLA,.25)
local rightLA = Stand:WaitForChild("RightLowerArm"):Clone()
for _, obj in pairs(rightLA:GetChildren()) do
if not obj:isA("BasePart") and not obj:isA("ManualWeld") then
obj:Destroy()
end
end
rightLA.CanCollide = false
rightLA.Anchored = true
rightLA.Parent = Folder
Debris:AddItem(rightLA,.25)
-- second parts
local leftHand = Stand:WaitForChild("LeftHand"):Clone()
for _, obj in pairs(leftHand:GetChildren()) do
if not obj:isA("BasePart") and not obj:isA("ManualWeld") then
obj:Destroy()
end
end
leftHand.CanCollide = false
leftHand.Anchored = false
leftHand.Parent = Folder
Debris:AddItem(leftHand,.25)
local rightHand = Stand:WaitForChild("RightHand"):Clone()
for _, obj in pairs(rightHand:GetChildren()) do
if not obj:isA("BasePart") and not obj:isA("ManualWeld") then
obj:Destroy()
end
end
rightHand.CanCollide = false
rightHand.Anchored = false
rightHand.Parent = Folder
Debris:AddItem(rightHand,.25)
local LeftUA = Stand:WaitForChild("LeftUpperArm"):Clone()
for _, obj in pairs(LeftUA:GetChildren()) do
if not obj:isA("BasePart") and not obj:isA("ManualWeld") then
obj:Destroy()
end
end
LeftUA.CanCollide = false
LeftUA.Anchored = false
LeftUA.Parent = Folder
Debris:AddItem(LeftUA,.25)
local RightUA = Stand:WaitForChild("RightUpperArm"):Clone()
for _, obj in pairs(RightUA:GetChildren()) do
if not obj:isA("BasePart") and not obj:isA("ManualWeld") then
obj:Destroy()
end
end
RightUA.CanCollide = false
RightUA.Anchored = false
RightUA.Parent = Folder
Debris:AddItem(RightUA,.25)
--CFrames for the primary parts
leftLA.CFrame = CFrame.new((Stand.PrimaryPart.CFrame * CFrame.new(math.random(-2,-1.5),math.random(-2,-2), -1)).p, pivotCFrame.p) * CFrame.Angles(math.rad(90),0,0)
rightLA.CFrame = CFrame.new((Stand.PrimaryPart.CFrame * CFrame.new(math.random(1.5,2),math.random(-2,-2), -1)).p, pivotCFrame.p) * CFrame.Angles(math.rad(90),0,0)
--CFrames for the secondary parts
leftHand.CFrame = leftLA.CFrame * CFrame.new(0,-(leftLA.size.Y/2),0)
rightHand.CFrame = rightLA.CFrame * CFrame.new(0,-(rightLA.size.Y/2),0)
LeftUA.CFrame = leftLA.CFrame * CFrame.new(0,(leftLA.size.Y/3),0)
RightUA.CFrame = rightLA.CFrame * CFrame.new(0,(rightLA.size.Y/3),0)
-- welding the secondary parts to the primary parts
local LWeld1 = Instance.new("ManualWeld")
LWeld1.Part0 = leftHand
LWeld1.Part1 = leftLA
LWeld1.C0 = LWeld1.Part0.CFrame:ToObjectSpace(LWeld1.Part1.CFrame)
LWeld1.Parent = LWeld1.Part0
local LWeld2 = Instance.new("ManualWeld")
LWeld2.Part0 = LeftUA
LWeld2.Part1 = leftLA
LWeld2.C0 = LWeld2.Part0.CFrame:ToObjectSpace(LWeld2.Part1.CFrame)
LWeld2.Parent = LWeld2.Part0
local RWeld1 = Instance.new("ManualWeld")
RWeld1.Part0 = rightHand
RWeld1.Part1 = rightLA
RWeld1.C0 = RWeld1.Part0.CFrame:ToObjectSpace(RWeld1.Part1.CFrame)
RWeld1.Parent = RWeld1.Part0
local RWeld2 = Instance.new("ManualWeld")
RWeld2.Part0 = RightUA
RWeld2.Part1 = rightLA
RWeld2.C0 = RWeld2.Part0.CFrame:ToObjectSpace(RWeld2.Part1.CFrame)
RWeld2.Parent = RWeld2.Part0
-- tweens for primary parts
local tween1 = TweenService:Create(leftLA,TweenInfo.new(.25),{Transparency = 1,CFrame = leftLA.CFrame * CFrame.new(0,-3,0)}):Play()
local tween2 = TweenService:Create(rightLA,TweenInfo.new(.25),{Transparency = 1,CFrame = rightLA.CFrame * CFrame.new(0,-3,0)}):Play()
--tweens for secondary parts
local tweenA1 = TweenService:Create(leftHand,TweenInfo.new(.25),{Transparency = 1}):Play()
local tweenA2 = TweenService:Create(LeftUA,TweenInfo.new(.25),{Transparency = 1}):Play()
local tweenB1 = TweenService:Create(rightHand,TweenInfo.new(.25),{Transparency = 1}):Play()
local tweenB2 = TweenService:Create(RightUA,TweenInfo.new(.25),{Transparency = 1}):Play()
local rayParams = RaycastParams.new()
rayParams.FilterDescendantsInstances = {Character}
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
local L_Start = leftLA.CFrame * CFrame.new(0,leftLA.size.Y/2,0)
local R_Start = rightLA.CFrame * CFrame.new(0,rightLA.size.Y/2,0)
local rayL = workspace:Raycast(L_Start.p, CFrame.new(L_Start.p, leftLA.CFrame.p).LookVector * 6,rayParams)
local rayR = workspace:Raycast(R_Start.p, CFrame.new(R_Start.p, rightLA.CFrame.p).LookVector * 6,rayParams)
if rayL then
local ehum = rayL.Instance.Parent:FindFirstChild("Humanoid")
if ehum then
if not DictionaryHandler.findPlayer(ehum, "BStunned") then
ehum:TakeDamage(Barrage_Handler.damage)
DictionaryHandler.addTo(ehum,"BStunned")
while wait(.7) do
DictionaryHandler.removeFrom(ehum,"BStunned")
end
else return
end
end
end
if rayR then
local ehum = rayR.Instance.Parent:FindFirstChild("Humanoid")
if ehum then
if not DictionaryHandler.findPlayer(ehum, "BStunned") then
ehum:TakeDamage(Barrage_Handler.damage)
DictionaryHandler.addTo(ehum,"BStunned")
while wait(.7) do
DictionaryHandler.removeFrom(ehum,"BStunned")
end
else return
end
end
end
wait(.1)
end
end
function Barrage_Handler.cleanUp(Folder)
Barrage_Handler.isactive = false
Folder:Destroy()
end
return Barrage_Handler
Thanks
By the way this is just the barragehandler and a modulescript