Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 17 Feb 2014 11:38 AM |
How would I get a random player from Players and teleport all the players except for the random one that I chose? I have a script already that teleports all the players to a given spot and I have a scope that selects a random player I just don't know how I would teleport all the players except for the random one. Here is part of the script(lines 6-9 is where the problem is):
while true do for i = 30, 0, -1 do wait(1) script.Parent.Text = i end local player = game.Players:players()[math.random(1, #game.Players:players())] for i, v in pairs(game.Players:GetChildren()) do v.Character:MoveTo(Vector3.new(500, 5, 0)) end script.Parent.Parent.Text1.Text = "Game in progress" script.Parent.Parent.Text2.Text = "Game ending in:"
for i = 60, 0, -1 do wait(1) script.Parent.Text = i end for i, v in pairs(game.Players:GetChildren()) do v.Character:MoveTo(Vector3.new(0, 5, 0)) end script.Parent.Parent.Text1.Text = "No game in progress" script.Parent.Parent.Text2.Text = "Time until next round:" end |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2014 11:41 AM |
| Add all players to a table and have two variables that choose randomly. |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 17 Feb 2014 11:42 AM |
that doesnt answer my question ._.
if i put them all in a table, i would still have trouble with it teleporting all but one random player |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2014 11:45 AM |
| Solution: Once you have the random player, clear the table. |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 17 Feb 2014 11:46 AM |
| I still don't understand how this is helping me... I am just getting more confused. |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2014 11:52 AM |
wow, you guys don't know 2 + 2 in scripting. -- sorry for the spaces, it's roblox filter's fault --game starts... -- here's the script players = game. Players: Get Children (take away this message just use the parenthesis) certain-player = math. random (1, # players) certain-player. Backpack. Value = false for loop = 1, # players do if players. Backpack. Value = = true then -- teleporting, etc.
|
|
|
| Report Abuse |
|
|
|
| 17 Feb 2014 11:53 AM |
| I mean honestly, that took me 2 seconds to figure out. Go take lessons or something. |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 17 Feb 2014 11:58 AM |
| I don't appreciate the negativity but thanks anyways. I just didn't think about that. But once the round is over, I would have to change the value back so he isn't chosen every time wouldn't I? |
|
|
| Report Abuse |
|
|
badmrpoo1
|
  |
| Joined: 20 Feb 2012 |
| Total Posts: 935 |
|
|
| 17 Feb 2014 11:59 AM |
| @Kyro, that would cause an error, you put many spaces in that. |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 17 Feb 2014 12:10 PM |
| Your way doesn't work kyro, the variable you put for the chosen person returns a number value |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 17 Feb 2014 12:15 PM |
| I fixed the way you did it but now Value isn't a valid member of backpack so would i have to insert a value into them? |
|
|
| Report Abuse |
|
|
iYoshiFox
|
  |
| Joined: 14 Apr 2012 |
| Total Posts: 1058 |
|
|
| 17 Feb 2014 12:54 PM |
local players = {}
local random = math.random(1, #players)
for i, v in pairs(game.Players:GetPlayers()) do table.insert(players, v.Name) end
for i, v in pairs(game.Players:GetPlayers()) do if i ~= random then v.Character:MoveTo(Vector3.new(ur pos)) end end |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 17 Feb 2014 01:02 PM |
iYoshi, i get this error with ur way...
Script:7: bad argument #2 to 'random' (interval is empty) |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 17 Feb 2014 01:04 PM |
| i think because the table was empty so i put like 7 after the table.insert |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 17 Feb 2014 01:06 PM |
| Ok it kind of works but it teleport all the players to the location including the randomly chosen one... back to square one :/ |
|
|
| Report Abuse |
|
|