devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 03:43 PM |
The output says: "Game script timeout" Can someone please help?
function RandomTeams() for i = 1,#players do teamNum = math.random(1,#teams) game.Players[players[i]].TeamColor = BrickColor.new(teams[teamNum]) teamName = teams[teamNum] lookingForTeam = true for _,v in pairs(game.Teams:GetChildren()) do if v.TeamColor == game.Players[players[i]].TeamColor then y = v.Name end end while lookingForTeam do if #game.Teams[y]:GetChildren() > 1 then game.Players[players[i]].TeamColor = BrickColor.new(teams[math.random(1,#teams)]) end team = game.Players[players[i]].TeamColor for _,v in pairs(game.Teams:GetChildren()) do if v.TeamColor == team then l = v.Name end end if #game.Teams[l]:GetChildren() == 1 then lookingForTeam = false end end end end
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 18 Dec 2014 03:45 PM |
This isn't your full script, I presume?
Also could you provide an output or a description what's not working? |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 03:47 PM |
Yeah, that's just a function and the entire output says this exactly:
Workspace.Main:234: Game script timout Content failed because HTTP 404(Not Found)
Those are the only things in red.
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 03:49 PM |
b1
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 04:12 PM |
b2
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
parkiet3
|
  |
| Joined: 16 Jul 2011 |
| Total Posts: 832 |
|
| |
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 04:24 PM |
Okay I added a wait() but the issue is that it's an infinite while loop, but it shouldn't be. What it should do is look at each player and place them on a random team AS LONG AS that team doesn't already have someone. If it has someone, it will place them on a different team and repeat that process until it finds an open team. Here is the function:
function RandomTeams() for i = 1,#players do teamNum = math.random(1,#teams) game.Players[players[i]].TeamColor = BrickColor.new(teams[teamNum]) teamName = teams[teamNum] lookingForTeam = true for _,v in pairs(game.Teams:GetChildren()) do if v.TeamColor == game.Players[players[i]].TeamColor then y = v.Name end end print("Right before while loop") while lookingForTeam == true do wait() print("Im inside the while loop") if #game.Teams[y]:GetChildren() > 1 then game.Players[players[i]].TeamColor = BrickColor.new(teams[math.random(1,#teams)]) end print("After the first if") team = game.Players[players[i]].TeamColor for _,v in pairs(game.Teams:GetChildren()) do if v.TeamColor == team then l = v.Name end end print("Made it through the for") if #game.Teams[l]:GetChildren() == 1 then lookingForTeam = false break end print("Passed the function") end end end
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
parkiet3
|
  |
| Joined: 16 Jul 2011 |
| Total Posts: 832 |
|
|
| 18 Dec 2014 04:27 PM |
Maybe try repeat -- script until lookingForTeam = false
|
|
|
| Report Abuse |
|
|
parkiet3
|
  |
| Joined: 16 Jul 2011 |
| Total Posts: 832 |
|
| |
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 05:43 PM |
I just tried it and it is still an infinite loop for some reason. Can anyone help?
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 05:58 PM |
bump
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 07:42 PM |
This is what I have(Still broken):
function RandomTeams() for i = 1,#players do teamNum = math.random(1,#teams) game.Players[players[i]].TeamColor = BrickColor.new(teams[teamNum]) teamName = teams[teamNum] lookingForTeam = true for _,v in pairs(game.Teams:GetChildren()) do if v.TeamColor == game.Players[players[i]].TeamColor then y = v.Name end end print("Right before while loop") repeat wait() if #game.Teams[y]:GetChildren() > 1 then game.Players[players[i]].TeamColor = BrickColor.new(teams[math.random(1,#teams)]) end team = game.Players[players[i]].TeamColor for _,v in pairs(game.Teams:GetChildren()) do if v.TeamColor == team then l = v.Name end end if #game.Teams[l]:GetChildren() == 1 then lookingForTeam = false end print("Passed the function") until lookingForTeam == false end end
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 08:20 PM |
bump Please help
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 08:52 PM |
Anyone?
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
anaIyze
|
  |
| Joined: 29 May 2014 |
| Total Posts: 2048 |
|
| |
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 09:06 PM |
idk where to put it though...
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
Centuryan
|
  |
| Joined: 25 Oct 2009 |
| Total Posts: 6415 |
|
|
| 18 Dec 2014 09:11 PM |
if #game.Teams[y]:GetChildren() > 1 then game.Players[players[i]].TeamColor = BrickColor.new(teams[math.random(1,#teams)]) break
try that |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 10:14 PM |
didn't work should I just retype it up and see if I fix it?
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 18 Dec 2014 10:23 PM |
buummpp
|| devTools | get out me mooms car | broom broom || |
|
|
| Report Abuse |
|
|
parkiet3
|
  |
| Joined: 16 Jul 2011 |
| Total Posts: 832 |
|
|
| 19 Dec 2014 01:53 AM |
| if #game.Teams[l]:GetChildren() == 1 then -- i dont get this part, so the looking only is false when there is 1 player in, what if there arent |
|
|
| Report Abuse |
|
|
parkiet3
|
  |
| Joined: 16 Jul 2011 |
| Total Posts: 832 |
|
|
| 19 Dec 2014 02:14 AM |
local plrs = game.Players:GetChildren()
tabel.sort(plrs, function (a,b) return math.random() > math.random() end) -- normally this should make a random player order
local teamcolors = ["",""] table.sort(plrs, function(a,b) return math.random() > math.random() end)
for i,v in pairs (plrs) do
if i < math.floor(#plrs/2) then v.TeamColor = teamcolors[1] else v.TeamColor = teamcolors[2] end
end |
|
|
| Report Abuse |
|
|
My7Inch
|
  |
| Joined: 01 Dec 2014 |
| Total Posts: 10 |
|
|
| 19 Dec 2014 07:06 AM |
| wat is this i dont get it how do i script like you guys please help me yes please do |
|
|
| Report Abuse |
|
|
parkiet3
|
  |
| Joined: 16 Jul 2011 |
| Total Posts: 832 |
|
| |
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 19 Dec 2014 09:32 AM |
| So in teamcolors do I need to put the team colors? |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 19 Dec 2014 09:35 AM |
| I'm trying to put each player on their own team. Maximum is 8 players, and I want it to just place them on a team randomly and make sure only one player is on that team. |
|
|
| Report Abuse |
|
|