generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Very complicated in my eyes

Previous Thread :: Next Thread 
Secretiverobocop is not online. Secretiverobocop
Joined: 23 Apr 2011
Total Posts: 510
11 Apr 2012 11:04 PM
To the average advanced scripter, it probably isnt, to me it is though.
It is supposed to take the people on the "Bright violet" team ONLY, and split them in half. One half will go on the blue team and the other will go on the red. Any ideas? I was thinking:

players = game.Players:GetChildren()
for i = 1, 2players do
if players[i].TeamColor == "Bright violet" then
players[i].TeamColor = BrickColor.new("Bright red")
end else end
for i = 2, 2players do
if players[i].TeamColor == "Bright violet" then
players[i].TeamColor = BrickColor.new("Bright blue")
end else end

The above is most likely incorrect, please help me.
Report Abuse
litozinnamon is not online. litozinnamon
Joined: 21 Dec 2009
Total Posts: 891
11 Apr 2012 11:40 PM
Try this:



players = game.Players:GetChildren()
local haha = 0
for i = 1, #players do
if players[i].TeamColor == BrickColor.new(""Bright violet") then
if haha == 0 then
haha = 1
players[i].TeamColor = BrickColor.new("Bright red")
else
haha = 0
players[i].TeamColor = BrickColor.new("Bright blue")
end
end
end
Report Abuse
Secretiverobocop is not online. Secretiverobocop
Joined: 23 Apr 2011
Total Posts: 510
11 Apr 2012 11:41 PM
Very clever, I'll try it. brb
Report Abuse
litozinnamon is not online. litozinnamon
Joined: 21 Dec 2009
Total Posts: 891
11 Apr 2012 11:50 PM
Well to explain that, I first corrected some syntax errors such as:

if players[i].TeamColor == "Bright violet" then
to
if players[i].TeamColor == BrickColor.new(""Bright violet") then

and

for i = 1, 2players do
to
for i = 1, #players do

Then I used a variable "haha" to alternate between the teams the players will join
when haha is 0, then the player will join as red and haha switches to 1. If it is not 0, then the player joins blue and haha switches to 0.

Don't mind my variable names =P
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image