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: Scramble on Click, Help?

Previous Thread :: Next Thread 
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
07 May 2014 10:19 PM
I want this to assign a player to a team when the brick is clicked. I'm pretty sure a script can't have two functions so I'm confused on how to fix that.

function h(hit)

function teamScrambler()
local players = {}
local team1 = {}
local team2 = {}
local p = game.Players:GetChildren()
for i = 1, #p do
table.insert(players, p[i])
end
for i = 1, #players do
local randomPlayer = math.random(1, #players)
local chosenPlayer = players[randomPlayer]
if #team1 == #team2 then
local ran = math.random(1, 2)
if ran == 1 then
chosenPlayer.TeamColor = BrickColor.new("Cyan")
table.insert(team1, chosenPlayer)
else
chosenPlayer.TeamColor = BrickColor.new("Bright red")
table.insert(team2, chosenPlayer)
end
elseif #team1 > #team2 then
chosenPlayer.TeamColor = BrickColor.new("Bright red")
table.insert(team2, chosenPlayer)
elseif #team1 < #team2 then
chosenPlayer.TeamColor = BrickColor.new("Cyan")
table.insert(team1, chosenPlayer)
end
table.remove(players, randomPlayer)
end
end

end
script.Parent.ClickDetector.MouseClick:connect(h)
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
07 May 2014 10:20 PM
A script can have 2 functions...
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
07 May 2014 10:21 PM
Correction
What I meant was it can have however many you want. Sorry.
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
07 May 2014 10:21 PM
Then why isn't this script working?
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
07 May 2014 10:35 PM
Bump
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
07 May 2014 10:41 PM
What does the output say and what are you trying to do?

This?
http://wiki.roblox.com/index.php/RebalanceTeams_(Method)
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
08 May 2014 02:36 AM
The output doesn't tell me anything regarding the script. I want to make it so that when a player clicks a brick, they are randomized onto a team. I have 4 teams, but only 2 of which are the teams that I want players to be randomized onto. The link you provided will balance the teams, but only across all teams. That's not what I want. I want two of the four teams balanced.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
08 May 2014 09:41 AM
You are making this a lot harder than it needs to be .-.

function OnClick(Player)
Team = math.random(0, 1)
if Team == 0 then
Player.TeamColor = BrickColor.new("Bright blue")
elseif Team == 1 then
Player.TeamColor = BrickColor.new("Bright red")
end
end
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
09 May 2014 11:50 AM
Nope. Not working.
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
12 May 2014 06:19 PM
Bump
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
12 May 2014 06:21 PM
script.Parent.MouseClick:connect(function(p)
local random = math.random(1,2)
if random == 1 then
p.TeamColor = BrickColor.new("Bright red")
else
p.TeamColor = BrickColor.new("Bright blue")
end
end)
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
12 May 2014 06:28 PM
That didn't work either. :/
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
13 May 2014 01:28 PM
Bump
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
13 May 2014 03:03 PM
Buuuuuuuuump
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
13 May 2014 09:54 PM
-____-
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
14 May 2014 01:18 PM
Still need help, people.....
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
14 May 2014 07:32 PM
...
Report Abuse
CloudStomper is not online. CloudStomper
Joined: 20 Apr 2014
Total Posts: 4
14 May 2014 07:53 PM
U haz click detector
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
15 May 2014 12:10 PM
Yes
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
17 May 2014 03:00 PM
...
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
17 May 2014 03:02 PM
script.Parent.MouseClick:connect(function(p) -- Is this script in the ClickDetector, if not, put in there for it to work
local random = math.random(1,2)
if random == 1 then
p.TeamColor = BrickColor.new("Bright red")
else
p.TeamColor = BrickColor.new("Bright blue")
end
end)
Report Abuse
Chubs1995 is not online. Chubs1995
Joined: 02 Sep 2007
Total Posts: 339
17 May 2014 09:44 PM
Thanks, that fixed it!
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