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

How would I go about teleporting 2 players?

Asked by 10 years ago

I was making my game but scripting is not my strongest area and I would like to know how to teleport 2 players stored in 2 variables 1 called F1 and the other F2. It would tp these to a given location and the other players (left over) to a different location again given.

1 answer

Log in to vote
0
Answered by 10 years ago

That would be something like this, it depends on what you have stored in F1 and F2. If they're characters then this will work.

local Area1 = Vector3.new() -- Put your first area and second area here
local Area2 = Vector3.new() -- this should be a Vector3 value
for index, player in pairs(game.Players:GetChildren()) do -- We loop through all players
    if player.Name == F1.Name or player.Name == F2.Name then -- Here we check if the current player is either player F1 or F2
        player.Torso.Position = Area1 -- If it's true then teleport to Area 1
    else
        player.Torso.Position = Area2 -- If it's false then teleport to Area 2
    end
0
Is Vector3 a set of co-ordinates if not how would I go about using them? space482 0 — 10y
0
Yes, you can do Vector3.new(0, 10, 25). These numbers represent the coords. damagex443 325 — 10y
0
Thanks for the help! space482 0 — 10y
Ad

Answer this question