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 » Scripters
Home Search
 

Re: Plane Teleport

Previous Thread :: Next Thread 
gloriousryan is not online. gloriousryan
Joined: 28 Feb 2010
Total Posts: 299
30 Mar 2016 04:40 PM
Im looking for somebody to give me a link or give me some tips on how to teleport people who are in a certain area when the countdown ends it would be something like this

function Teleport()
--(Insert Teleport people here)
-- Could I do something with :MoveTo for this or no?
end
function Countdown()
while i <= 30 do
wait(1)
game.StarterGui.frame.Text = ("Game starting in "),i)
end
end
Countdown()
Report Abuse
Kryddan is not online. Kryddan
Joined: 12 Dec 2014
Total Posts: 310
30 Mar 2016 04:42 PM
don't got time to go deep but for the teleport stuff use :MoveTo onto the character model it will make them teleport instead of walking when using it on a humanoid.
Report Abuse
gloriousryan is not online. gloriousryan
Joined: 28 Feb 2010
Total Posts: 299
30 Mar 2016 04:44 PM
I know how to use :MoveTo after using :GetPlayerFromCharacter
and then use that to teleport them, but I want to teleport a entire group of people
Report Abuse
gloriousryan is not online. gloriousryan
Joined: 28 Feb 2010
Total Posts: 299
30 Mar 2016 05:15 PM
bump
Report Abuse
Kryddan is not online. Kryddan
Joined: 12 Dec 2014
Total Posts: 310
30 Mar 2016 05:19 PM
BRUH!! ...

I said :MoveTo on character model in "WORKSPACE" not the player it self.

for _,v in pairs (game.Players:GetChildren()) do
if v.Character and v.Character:FindFirstChild("Humanoid").Health > 0 then
v.Character:MoveTo(...)
end
end
Report Abuse
gloriousryan is not online. gloriousryan
Joined: 28 Feb 2010
Total Posts: 299
30 Mar 2016 05:20 PM
can you please explain what each line is doing? sorry, this is just a little advanced for myself.
Report Abuse
Kryddan is not online. Kryddan
Joined: 12 Dec 2014
Total Posts: 310
30 Mar 2016 05:49 PM
Line 1: for _,v in pairs (game.Players:GetChildren()) do
Line 2: if v.Character and v.Character:FindFirstChild("Humanoid").Health > 0 then
Line 3: v.Character:MoveTo(...)
Line 4: end
Line 5: end


Line 1: I assume you have worked with numeric for loops like this, for i = 1,10 do. Something like that? Well this is a generic for loop which returns index and a value compared to numeric which only haves a index. Generic for loop is mostly used when working objects such as parts or players, doesn't mean that is the only way of using it.

for _,v the "_" is the index but it can be whatever you want such as "i" the most used index in numeric loops that I have encounterd, "v" is the value of the object encounterd, as with the index "v" can be changed.

in should just be there nothing to exlpain.

Lets talk about the diffrence between pairs and ipairs.

ipairs and pairs are very similar; both of them are used to get pairs of values in tables. The biggest difference is that ipairs uses a different iterator than pairs.

So how does this affect how they function?

Well, ipairs uses an iterator that only returns pairs of values attributed to numerical keys. This means that they can only return values defined in list format. In addition, if ipairs encounters any nil value, it will stop in its tracks. Here's an example of that.

list = {1,2,nil,3}
for index, value in ipairs(list) do
print(value)
end
output: 1 2
Note that 3 wasn't printed, because ipairs encounterd a nil value.

pairs, on the other hand, iterates through the entire table and returns keys that are non-numerical as well. This makes them particularly useful in dictionaries or tables with mixed entries.

I use pairs in my code because of the fact that it would continue if it encounterd a nil value which would happend very rarely when loop players, that is because the only reason it could return nil is if a player leaves just as the for loop is executed, in the exact milisecond. Summary, just to be safe.

Last part of the generic is the brackets, in this you would store a table. In the example before we use the list table, but in my code I sent you we use (game.Players:GetChildren()), that isn't a table is it? When we use :GetChildren() then it returns all children as a table, so yes it is.

Line 2: if v.Character and v.Character:FindFirstChild("Humanoid").Health > 0 then

Simple if statement that checks if the player (v) got a character and if the player is alive by checking the humanoid's health property. If the if statement returns true we proceed.

Line 3: We teleport the player by calling :MoveTo method on the players character, which teleports the model to a specified Vector3 position.

Note:
-The dots inside :MoveTo(HERE) is where you would enter the position.
-It has to be a Vector3 value.
-If terrain or a part is located where you try to teleport then the model will be moved up in the y axis.

Line 4: Ends the if statment

Line 5: Ends the for loop.



Report Abuse
Kryddan is not online. Kryddan
Joined: 12 Dec 2014
Total Posts: 310
30 Mar 2016 05:50 PM
I hope that is clear enough if not tell my what you didn't understand.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
30 Mar 2016 05:58 PM
Lol.

for i,v in next, game.Players:GetPlayers() do
v.Character:MoveTo(workspace.Spawn.Position + Vector3.new(0,1,0))
end
Report Abuse
Kryddan is not online. Kryddan
Joined: 12 Dec 2014
Total Posts: 310
30 Mar 2016 06:03 PM
@TimeTicks

That works but could error...
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
30 Mar 2016 06:04 PM
In most cases, it won't so don't worry about it
Report Abuse
Kryddan is not online. Kryddan
Joined: 12 Dec 2014
Total Posts: 310
30 Mar 2016 06:05 PM
ye but better to be safe so...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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