for i = 1, 5, 1 do
local _ : Part = Hitbox:Clone()
_.CFrame = char.PrimaryPart.CFrame * CFrame.new(0, 0, -4)
_.Parent = game.Workspace
task.wait(waitingTime + 2)
_:Destroy()
end
local hitboxTable = {0,0,-4, 2,2,-5, -2,-1,-4, -1,-2,-5, 1,-2.5,-5}
local function hitBoxFunction(value)
local clonedHitBox = Hitbox:Clone()
clonedHitBox.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(value)
clonedHitBox.Parent = workspace
task.wait(2)
clonedHitBox:Destroy()
end
for index, value in pairs(hitboxTable) do
task.spawn(hitBoxFunction, value)
task.wait(waitingTime)
end
Im not sure if this works, test it. If u add another CFrame to the hitboxTable it will repeat more or less when u remove CFrames on the Table.
local HitboxLocations = {
CFrame.new(0,0,-4),
CFrame.new(2,2,-5),
CFrame.new(-2,-1,-4),
CFrame.new(-1,-2,-5),
CFrame.new(1,-2.5,-5)
}
local Hitboxes = {}
for _, hitboxLocation: CFrame in HitboxLocations do
local hitbox = Hitbox:Clone()
hitbox.CFrame = hitboxLocation
table.insert(Hitboxes, hitbox)
end
for _, hitbox in Hitboxes do
hitbox.Parent = workspace
task.delay(waitingTime + 2, hitbox.Destroy, hitbox)
end
local hitboxTable = {CFrame.new(0,0,-4), CFrame.new(2,2,-5), CFrame.new(-2,-1,-4), CFrame.new(-1,-2,-5), CFrame.new(1,-2.5,-5)}
local function hitBoxFunction(value)
local clonedHitBox = Hitbox:Clone()
clonedHitBox.CFrame = char.HumanoidRootPart.CFrame * value
clonedHitBox.Parent = workspace
task.wait(2)
clonedHitBox:Destroy()
end
for index, value in pairs(hitboxTable) do
task.spawn(hitBoxFunction, value)
task.wait(waitingTime)
end
The pairs loops through all CFrames in the hitboxTable. Every time when it loops, it fires a Function with the value inside the hitBoxTable but im firing the hitBoxFunction with task.spawn so it dont waits 2 seconds and fires instantly another funtion after the waitingTime is done. Now inside the hitBoxFunction it spawns a hitBox with the value and destroys it after 2 seconds.