IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 29 Sep 2013 03:19 PM |
Anyone know why these lines does not seem to be working? It's meant to select a random player. if sections[2]=="random" then listplayers={} table.insert(listplayers, game.Players:GetChildren()[math.random(#game.Players:GetChildren())].Name) po=listplayers[1] if (x[i]) and (string.lower(x[i].Name)==string.lower(sections[3])) then if Team~=nil then team=x[i] game.Players:findFirstChild(po).TeamColor=team.TeamColor end wait(.001) listplayers={} end end |
|
|
| Report Abuse |
|
|
| |
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 29 Sep 2013 03:25 PM |
| There were no errors displayed. |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2013 03:26 PM |
| I see, a logic problem, let me reread it, post the whole script too, if that isn't the whole script. |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 29 Sep 2013 03:30 PM |
Well the lines are within an admin commands script. it's something I was trying to implement within the script. This is the "teaming" section that it is for:
elseif (sections[1]=="team" or sections[1]=="changeteam") and (sections[2]~=nil and sections[3]~=nil) then --changeteam !team player teamname or !team all teamname local player1=findPlayer(sections[2]) local x=game.Teams:GetChildren() for i=1,#x do if sections[2]=="all" then if (x[i]) and (string.lower(x[i].Name)==string.lower(sections[3])) then for _,v in pairs(game.Players:GetPlayers()) do if (v~=nil and v.Character~=nil) then team=x[i] v.TeamColor = team.TeamColor end end end end if sections[2]=="random" then listplayers={} table.insert(listplayers, game.Players:GetChildren()[math.random(#game.Players:GetChildren())].Name) po=listplayers[1] if (x[i]) and (string.lower(x[i].Name)==string.lower(sections[3])) then if Team~=nil then team=x[i] game.Players:findFirstChild(po).TeamColor=team.TeamColor end wait(.001) listplayers={} end end end local team=nil local x=teams:GetChildren() for i=1,#x do if (x[i]) and (string.lower(x[i].Name)==string.lower(sections[3])) then team=x[i] break end end if (player1 and team) then player1.TeamColor=team.TeamColor else end |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2013 03:32 PM |
| Would it be fine if I totally remake it for you? |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
| |
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 29 Sep 2013 03:42 PM |
| Although that's how the admin commands run, so it needs to be similar to that. I just wanted to implement a "random" command so when I say "!team random teamname" it picks a random player. |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2013 03:48 PM |
elseif (sections[1]=="team" or sections[1]=="changeteam") and (sections[2]~=nil and sections[3]~=nil) then --changeteam !team player teamname or !team all teamname local player1=findPlayer(sections[2]) local x=game.Teams:GetChildren() for i=1,#x do if sections[2]=="all" then if (x[i]) and (string.lower(x[i].Name)==string.lower(sections[3])) then for _,v in pairs(game.Players:GetPlayers()) do if (v~=nil and v.Character~=nil) then team=x[i] v.TeamColor = team.TeamColor end end end end elseif sections[2]=="random" then listplayers={} table.insert(listplayers, game.Players:GetChildren()[math.random(#game.Players:GetChildren())].Name) po=listplayers[1] if (x[i]) and (string.lower(x[i].Name)==string.lower(sections[3])) then if Team~=nil then team=x[i] game.Players:findFirstChild(po).TeamColor=team.TeamColor end wait(.001) listplayers={} end end end local team=nil local x=teams:GetChildren() for i=1,#x do if (x[i]) and (string.lower(x[i].Name)==string.lower(sections[3])) then team=x[i] break end end if (player1 and team) then player1.TeamColor=team.TeamColor else end |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 30 Sep 2013 09:27 AM |
It didn't seem to work? It keeps saying there should be an end above the "elseif sections[2]=="random" |
|
|
| Report Abuse |
|
|
|
| 01 Oct 2013 08:28 AM |
Sorry for late reply, how about this?
elseif (sections[1]=="team" or sections[1]=="changeteam") and (sections[2]~=nil and sections[3]~=nil) then --changeteam !team player teamname or !team all teamname local player1=findPlayer(sections[2]) local x=game.Teams:GetChildren() for i=1,#x do if sections[2]=="all" then if (x[i]) and (string.lower(x[i].Name)==string.lower(sections[3])) then for _,v in pairs(game.Players:GetPlayers()) do if (v~=nil and v.Character~=nil) then team=x[i] v.TeamColor = team.TeamColor end end end elseif sections[2]=="random" then listplayers={} table.insert(listplayers, game.Players:GetChildren()[math.random(#game.Players:GetChildren())].Name) po=listplayers[1] if (x[i]) and (string.lower(x[i].Name)==string.lower(sections[3])) then if Team~=nil then team=x[i] game.Players:findFirstChild(po).TeamColor=team.TeamColor end wait(.001) listplayers={} end end end local team=nil local x=teams:GetChildren() for i=1,#x do if (x[i]) and (string.lower(x[i].Name)==string.lower(sections[3])) then team=x[i] break end end if (player1 and team) then player1.TeamColor=team.TeamColor else end |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 02 Oct 2013 09:50 AM |
| Alright, I'll try this thanks! |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 02 Oct 2013 09:54 AM |
Hm, the: "!team all teamnamehere" works and "!team playername teamnamehere" works? but the random doesn't? |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2013 05:01 PM |
| Eh, BRB then, I'll remake it. |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
| |
|