How to Determine Number Of Arms In Barrage Script

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.

Would be nice to know what “Thread Handler” is, but it’s in the main() function, instead of calling it on each heartbeat, delete all of that and do
for i = 1,3 do
thread.newThread(barrage)
end

Threadhandler creates a coroutine.wrap for the function.

I see, anyways running a for loop with the “barrage” function should work to create the desired amount of punches. To be honest the scripter here shouldn’t have used .Heartbeat here, as the attack shouldn’t be dependent on the users FPS, imagine someone with a 3090 and a FPS unlocker plays this game, 320 punches per second is a bit too much :rofl:

For loop works for some numbers only due to it being dependent on how fast the punches also disappear but I guess I would have to modify it even further so that when one of the punches disappears, another appears instead of appearing before the initial one disappears and having more punches present than intended. Also I didn’t know heartbeat changes as FPS changes, something I will consider.