Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to teleport to diffrent positions?

Asked by 8 years ago
Edited 8 years ago

I want to know how to teleport players to two different positions. So far I have nothing. I've only just started scripting.

I mean like there are two positions and I need it to choose one. My position is where the player ends up, but with a five stud offset.

0
What do you mean two different positions? Like you have two random locations on the map you can teleport to? In that case you could probably have a table with two different CFrame values and CFrame the Torso to a random location such as Locations[math.random(#Locations)]. M39a9am3R 3210 — 8y

1 answer

Log in to vote
2
Answered by
farrizbb 465 Moderation Voter
8 years ago
Edited 8 years ago

Okay lets see what you want because you cant really have 1 part in two different places though we have a better option we can make it so they are basically in two different places just really super fast .Another option is cloning and then putting them in two differnet places. Though this is probably all complicated for you since you are new so lets start of with CFrame CFrame is basically Position,but better CFrame takes Rotation as well as the Position and also just doesn't go through objects like Position.So to use CFrame well there is a lot of CFrame so here's the wiki http://wiki.roblox.com/index.php?title=CFrame anyways ill talk about CFrame and CFrame.new basically if you do a simple script like

1Part.CFrame = suchandsuch.CFrame

You are simply getting another CFrame and changing the current CFrame to that CFrame.new is simply making a new CFrame so

1Part.CFrame = CFrame.new(x,y,z)

Anyways know you know CFrame lets get started on with the cloning method since that is easier ish. before i do this ill give a brief explanation of functions basically they have information and they stop copy and pasting.

01    function Clone()
02         local c = game.Workspace.Part:Clone()--this is a variable it is used to shorten scripts
03         c.Name = "faker"--change the name of the cloned part
04         c.Parent = game.workspace
05         c.CFrame = CFrame.new(x,y,z)--change it to your liking
06         game.Workspace.Part.CFrame = CFrame.new(x,y,z)-- this will put them in two different             places assuming you did different values
07         wait(3)
08 
09end--btw anything after the end is not apart of the function
10Clone()--this runs the function

Okay this is one way to do and probably the best i don't recommend using the next one A brief explanation on loops loops repeat information untill something is met/not met the repeat function well you can probably guess what it does it repeats information until something is true

1--you don't have to make a function for this one i just wanted to do it xD
2function yo()
3    game.Workspace.Part.CFrame = CFrame.new(x,y,z)
4    game.Workspace.Part.CFrame = CFrame.new(x,y,z)
5end
6repeat
7    yo()
8wait()
9until (put some information here like)game.Workspace.Part.Anchored == true

I hope i helped , farrizbb signing out.

Ad

Answer this question