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 7 years ago
Edited 7 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 — 7y

1 answer

Log in to vote
2
Answered by
farrizbb 465 Moderation Voter
7 years ago
Edited 7 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

Part.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

Part.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.

    function Clone()
         local c = game.Workspace.Part:Clone()--this is a variable it is used to shorten scripts
         c.Name = "faker"--change the name of the cloned part
         c.Parent = game.workspace
         c.CFrame = CFrame.new(x,y,z)--change it to your liking
         game.Workspace.Part.CFrame = CFrame.new(x,y,z)-- this will put them in two different             places assuming you did different values
         wait(3)

end--btw anything after the end is not apart of the function
Clone()--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

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

I hope i helped , farrizbb signing out.

Ad

Answer this question