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

I need help with my number of player script. Can someone help me?

I'm testing my game and I realize that my script can only have 1 player in it. If I change the number, the game must contain that number of players. Please help me try and find a solution.

for i = 1, #player do

if m == 1 then
			msg.Parent = game.Workspace
			msg.Text = "Choosing Map..."
			wait(3)
			msg.Text = "Map Chosen: Classic"
			wait(3)
			msg.Text = "Loading."
			wait(1)
			msg.Text = "Loading.."
			wait(1)
			msg.Text = "Loading..."
			wait(1)
			msg.Text = "Loading."
			wait(1)
			msg.Text = "Loading.."
			wait(1)
			msg.Text = "Loading..."
			wait(2)
			msg:remove()
			game.Lighting.LinkedSword:clone().Parent = player[i].Backpack
			game.Lighting.RocketLauncher:clone().Parent = player[i].Backpack
			game.Workspace.Sounds.Intermission:Stop()
			game.Workspace.Sounds.Arena:Play()
			wait(0)
			target = Vector3.new(-486.5, -17.19, 486.5)
			for i, v in pairs(game.Players:GetChildren()) do 
			v.Character.Torso.CFrame = CFrame.new(target + Vector3.new(0, i * 5, 0))
			end
			game.Lighting.ForceField:clone().Parent = player[i].Character
			game.Workspace.ScreenGui:clone().Parent = player[i].PlayerGui
			game.Workspace.GameSpawnLabel.TextLabel1:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(1)
			player[i].PlayerGui.ScreenGui.TextLabel1:Remove()
			game.Workspace.GameSpawnLabel.TextLabel2:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(1)
			player[i].PlayerGui.ScreenGui.TextLabel2:Remove()
			game.Workspace.GameSpawnLabel.TextLabel3:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(1)
			player[i].PlayerGui.ScreenGui.TextLabel3:Remove()
			game.Workspace.GameSpawnLabel.TextLabel4:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(1)
			player[i].PlayerGui.ScreenGui.TextLabel4:Remove()
			game.Workspace.GameSpawnLabel.TextLabel5:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(1)
			player[i].PlayerGui.ScreenGui.TextLabel5:Remove()
			game.Workspace.GameSpawnLabel.TextLabel6:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(1)
			player[i].PlayerGui.ScreenGui.TextLabel6:Remove()
			game.Workspace.GameSpawnLabel.TextLabel7:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(1)
			player[i].PlayerGui.ScreenGui.TextLabel7:Remove()
			game.Workspace.GameSpawnLabel.TextLabel8:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(1)
			player[i].PlayerGui.ScreenGui.TextLabel8:Remove()
			game.Workspace.GameSpawnLabel.TextLabel9:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(1)
			player[i].PlayerGui.ScreenGui.TextLabel9:Remove()
			game.Workspace.GameSpawnLabel.zTextLabel10:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(1)
			player[i].PlayerGui.ScreenGui.zTextLabel10:Remove()
			game.Workspace.GameSpawnLabel.zTextLabel11:clone().Parent = player[i].PlayerGui.ScreenGui
			wait(2)
			player[i].PlayerGui.ScreenGui:Remove()
			player[i].Character.ForceField:Remove()

2 comments

0

Dude, use for loops when you want do something a certain number of times, it's much easier than just pasting your code over and over again.

0

use >= (number) . it makes it work if theres more then or equal to that number specified... http://wiki.roblox.com/index.php/Conditional_statement

1 answer

You can use the NumPlayers function which gives the number of players in the server at the current time.

If I helped, please give thanks by accepting and upvoting my answer. If you have any further questions, feel free to comment below.

2 comments

0

Im not sure what you mean by that. Add NumPlayers like this? for i = NumPlayers, #player do

0

I'm not sure specifically what you are trying to do, but NumPlayers returns a number of players in your game. If you would like to use this in a for loop then go ahead!

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