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: Changing a players team

Previous Thread :: Next Thread 
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
05 Nov 2013 03:43 PM
How?

b = game.Teams:findFirstChild("Red Bloxxers") -- this is for u mr forum
a = game.Players:GetChildren()

for i = 1, #a do
a[i].TeamColor = b
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
05 Nov 2013 03:45 PM
a[i].TeamColor = b.TeamColor



Das ees it.
Report Abuse
janthran is not online. janthran
Joined: 15 May 2009
Total Posts: 17429
05 Nov 2013 03:51 PM
why do people use a[i] instead of just using a pairs loop?
That's a legitimate question
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
05 Nov 2013 03:53 PM
I use it for matching two tables, mainly just spawning because randomization is absurd.


Ex.

spawns = {spawn1,spawn2,spawn3}
parts = {workspace.Part1,workspace.Part2,workspace.Part}

for i = 1,#parts do
part[i].Position = spawns[i].Position
end
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
05 Nov 2013 03:56 PM
@Bebee

spawns = {spawn1,spawn2,spawn3}
parts = {workspace.Part1,workspace.Part2,workspace.Part}

for i,v = in pairs (parts) do
v.Position = spawns[i].Position
end
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
05 Nov 2013 03:58 PM
so if id i = #a/2 do

would that put half players on one team?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
05 Nov 2013 03:58 PM
^ Despite having an up side effect, the extra 1 second it takes is not worth it.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
05 Nov 2013 03:59 PM
FFFFFF... Ninja'd.


And it would return nil.
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
05 Nov 2013 04:00 PM
hmmmmm then whats a compromise? math.floor?
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
05 Nov 2013 04:01 PM
here we go!

for i = 1, math.floor((#a/2)) do
a[1].TeamColor = "Really black"
table.remove(a, 1)
end

for i = 1, #a do
a[i].TeamColor = "Pastel orange"
end

any errors before i use it?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
05 Nov 2013 04:01 PM
*Return 1
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
05 Nov 2013 04:01 PM
"^ Despite having an up side effect, the extra 1 second it takes is not worth it."
(That was for me right?)
What
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
05 Nov 2013 04:02 PM
where would i return 1?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
05 Nov 2013 04:05 PM
-- That wasn't directed towards you directly. Here's the edited script.


for i = 1,
math.floor((#a/2)) do -- Uhmmm why do that? You mean #a simply?
a[i].TeamColor = BrickColor.new("Really black")
table.remove(a, i) -- Useless, but why not?
end

for i = 1, #a do
a[i].TeamColor = BrickColor.new("Pastel orange")
end
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
05 Nov 2013 04:07 PM
Oh I get it. Just stick with that script and it'll be fine.
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
05 Nov 2013 04:08 PM
I meant one hald over here

the rest here
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