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: I need help with a script

Previous Thread :: Next Thread 
TheSheepGoat is not online. TheSheepGoat
Joined: 17 Aug 2012
Total Posts: 29
23 Aug 2012 10:14 AM
How would i grab 1 random person and teleport him her/him to a certain location?
Report Abuse
Stealthah is not online. Stealthah
Joined: 18 Aug 2012
Total Posts: 288
23 Aug 2012 10:14 AM
Scripting.
Report Abuse
BAUER102 is not online. BAUER102
Joined: 03 Apr 2010
Total Posts: 5936
23 Aug 2012 10:38 AM
The script should look like this:

- Get a table of all players
- Use math.random to choose one
- Check, if his character does exist
- If yes, then teleport him

And since I'm in such a good mood I'll write the script for you, too.

local Position = Vector3.new(0,10,0) -- You obviously need to change the position

function TeleportRandom()
-- Get the table of all players
local players = game:GetService("Players"):GetPlayers()
-- Choose one
local chosen = players[math.random(1,#players)]
-- Does his character exists? We don't want to cause an error.
if (chosen.Character==nil) then return end
-- Does his torso exists?
if (chosen.Character:FindFirstChild("Torso")==nil) then return end
-- MoveTo() is useful for this.
chosen.Character:MoveTo(Position)
end

Feel free to ask, if you don't understand something of it.
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