I have a barrage attack script and it’s working as intended but I want to modify it so that I can determine how many arms I want present during the barrage. I’m struggling to come up with an approach to get a specific amount of arms present.
Like in this video there are multiple arms flying around. Let’s say I only want 2 or 3 arms flying and not this many. I can’t seem to figure out a way to rewrite it to be able to change it.
Here is the script:
local modules = game:GetService("ServerScriptService").Modules
local bezier = require(modules.Bezier)
local thread = require(modules.ThreadHandler)
local tweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")
local npc = script.Parent
local hum = npc.Humanoid
local hrp = hum.RootPart
function main()
runService.Heartbeat:Connect(function()
thread.newThread(barrage)
end)
end
function barrage()
local hrpSize = {
x = hrp.Size.X,
y = hrp.Size.Y,
z = hrp.Size.Z
}
local rnd = Random.new()
local part = workspace.testpart:Clone()
part.CFrame = hrp.CFrame
part.CanCollide = false
part.Anchored = true
part.Parent = workspace
-- Offsets for Bezier Curve Randomness Effect
local offsets = {
startOffset = CFrame.new(rnd:NextNumber(-hrpSize.x, hrpSize.x), rnd:NextNumber(hrpSize.y * -0.25, hrpSize.y), rnd:NextNumber(hrpSize.z / -2, hrpSize.z)),
curveOffset = CFrame.new(rnd:NextNumber(-hrpSize.x * 2.75, hrpSize.x * 2.75), rnd:NextNumber(-hrpSize.y * 2.75, hrpSize.y * 2.75), rnd:NextNumber(hrpSize.z * -1.5, hrpSize.z * 1.5)),
targetOffset = CFrame.new(rnd:NextNumber(hrpSize.x * -1.33, hrpSize.x * 1.33), rnd:NextNumber(hrpSize.y / -2, hrpSize.y), rnd:NextNumber(-hrpSize.z, hrpSize.z))
}
-- Barrage Attack Range
local barrageRange = rnd:NextNumber(7, 10)
local attackRange = hrp.CFrame.LookVector * barrageRange
-- Bezier Curve Points
local startPoint = (hrp.CFrame * offsets.startOffset).Position
local curvePoint = (hrp.CFrame * offsets.curveOffset).Position
local targetPoint = (hrp.CFrame * offsets.targetOffset + attackRange).Position
-- Tween duration
local duration = 0.1
local tween = nil
local total = 10
for i = 1, total do
i /= total
local finalPosition = bezier.quadraticBezier(i, startPoint, curvePoint, targetPoint)
tween = tweenService:Create(part, TweenInfo.new(duration, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out), {Position = finalPosition})
tween:Play()
task.wait()
end
tween.Completed:Connect(function()
part:Destroy()
end)
end
main()
Also if I am doing this in the worst way possible then you could tell me that too.
