Players attacked one by one

Im making an ability where when you say the word player around you get pushed .

The issue is that the players are getting attacked an pushed one by one instead of all at once .

is there another way to attack nearby players Instead of i v pairs ```lua
for i,v in pairs(workspace:GetChildren()) do
if v:findFirstChild(“HumanoidRootPart”) and v ~= c then

                if (v.HumanoidRootPart.Position - c.HumanoidRootPart.Position).magnitude < 10 then```

Also this is just the part of the script handling finding the players to attack .
Im just trying to find new sources to attack nearby players .

1 Like

Not really, you have to properly loop through every player using some sort of pairs loop in order to handle a proper sanity check

Not exactly sure what your full on script is, but I’m assuming that c is whoever chatted “player”?

for _, Plr in pairs(game.Players:GetPlayers()) do
    local Character = Plr.Character

    if Character then
        if (Character.HumanoidRootPart.Position - c.HumanoidRootPart.Position).Magnitude < 10 then
            --Do your attack/pushing here
        end
    end
end

You could try using coroutine.

for i, v in pairs(workspace:GetChildren()) do
	if v:FindFirstChild("HumanoidRootPart") and v ~= c then
		local cor = coroutine.wrap(function()
			-- Do whatever you need here
		end)
		cor()
	end
end