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: Script?

Previous Thread :: Next Thread 
IceOrb is not online. 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
AndroidKitKat is not online. AndroidKitKat
Joined: 21 Sep 2013
Total Posts: 1525
29 Sep 2013 03:23 PM
Logs/errors please.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
29 Sep 2013 03:25 PM
There were no errors displayed.
Report Abuse
AndroidKitKat is not online. AndroidKitKat
Joined: 21 Sep 2013
Total Posts: 1525
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 is not online. 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
AndroidKitKat is not online. AndroidKitKat
Joined: 21 Sep 2013
Total Posts: 1525
29 Sep 2013 03:32 PM
Would it be fine if I totally remake it for you?
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
29 Sep 2013 03:41 PM
Sure!
Report Abuse
IceOrb is not online. 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
AndroidKitKat is not online. AndroidKitKat
Joined: 21 Sep 2013
Total Posts: 1525
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 is not online. 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
AndroidKitKat is not online. AndroidKitKat
Joined: 21 Sep 2013
Total Posts: 1525
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 is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
02 Oct 2013 09:50 AM
Alright, I'll try this thanks!
Report Abuse
IceOrb is not online. 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
AndroidKitKat is not online. AndroidKitKat
Joined: 21 Sep 2013
Total Posts: 1525
02 Oct 2013 05:01 PM
Eh, BRB then, I'll remake it.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
03 Oct 2013 11:57 AM
Alright thanks!
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