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: How would I??

Previous Thread :: Next Thread 
Vyxium is not online. 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
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
17 Feb 2014 11:41 AM
Add all players to a table and have two variables that choose randomly.
Report Abuse
Vyxium is not online. 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
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
17 Feb 2014 11:45 AM
Solution: Once you have the random player, clear the table.
Report Abuse
Vyxium is not online. 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
Kyrothehero is not online. Kyrothehero
Joined: 14 Aug 2012
Total Posts: 306
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
Kyrothehero is not online. Kyrothehero
Joined: 14 Aug 2012
Total Posts: 306
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
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