Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make my script fire on multiple people, instead of one at a time?

I made a script that gets the opponents around another player, and inserts BodyVelocity on them that stops them in the air. Afterwards, the script creates a part on the opponents, but the scripts only fires one at a time. How can i fix this, so that it can fire on the opponents all at once.

baseAtk = 25
replicatedstorage = game:GetService("ReplicatedStorage")
RicoClass = replicatedstorage.RicoClass
Ult = RicoClass:FindFirstChild("Ultimate")
debounce = true
tool = script.Parent.Parent.Parent


Ult.OnServerEvent:connect(function(player)
local players = game.Workspace:GetChildren()
local root = player.Character.HumanoidRootPart
local bv = Instance.new("BodyVelocity")

for i,v in pairs(players)do
local here = v:findFirstChild("Humanoid")
	if v:findFirstChild("Humanoid")and here ~= player.Character:FindFirstChild("Humanoid") then
		if (root.Position - v.UpperTorso.Position).magnitude <=35 then

		bv.Parent = v.HumanoidRootPart
		bv.MaxForce = Vector3.new(1e8,1e8,1e8)
		bv.Velocity = v.HumanoidRootPart.CFrame.upVector * 23
		wait()
			for i = 23,-1,-1 do
				wait(0.01)
				bv.Velocity = v.HumanoidRootPart.CFrame.upVector + Vector3.new(0,i,0)
			end
local l = RicoClass.SmallWave:clone()
l.Parent = game:GetService("Workspace").Attacks["Rico's Attacks"]
l.Transparency = 1
l.LightningBolt.Disabled = true
l.CFrame = CFrame.new(v.UpperTorso.Position)

for b = 1,0,-0.2 do
	wait(0.1)
		l.Transparency = b
		l.Size = l.Size + Vector3.new(b,b,b)
		l.LightningBolt.Disabled = false
	end
	end
	end
end	
end)

1 answer

Very simple use a for loop like this

for i,Player in pairs(game.Players:GetPlayers())
print(Player.Name)
end

this code will print the names of everyone in the server so if there was 3 people in the server it would print those 3 players names.

4 comments

0

Im not sure how i can make this answer correlate to fix my problem...

0

I'm trying to get people around the player, not just simply get people in players...

0

He's not giving you a flat out answer. Use that script and the knowledge of what it does, and using your brain, figure out how to make them work together.

0

correct.

This discussion is preserved as it was. New answers, comments, and votes are closed.