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

How to make it so only one player is teleported?

Asked by 7 years ago

This script teleports everyone. Is there a way to make it so it teleports one player instead?

target = Vector3.new(-486.5, -16.79, 486.5)
for i, v in pairs(game.Players:GetChildren()) do 
v.Character.Torso.CFrame = CFrame.new(target + Vector3.new(0, i * 5, 0))
1
It's in a for loop.. legosweat 334 — 7y

2 answers

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

Simply remove your generic for loop, and define a specific player you'd like to teleport and you should be good.

--This is the player that will be teleported.
player = game.Players.TargetPlayerName
target = Vector3.new(-486.5, -16.79, 486.5)

--reference the predefined player here
player.Character.Torso.CFrame = CFrame.new(target + Vector3.new(0, 5, 0))
0
can you make it so it finds the player on a touch CardboardedCharacter 53 — 7y
0
because im not using just any player, the "TargetPlayerName" needs to be the name of the player that touches a brick CardboardedCharacter 53 — 7y
1
sorry for not accepting this earlier lol CardboardedCharacter 53 — 7y
0
LOL THANKS MATE Goulstem 8144 — 7y
Ad
Log in to vote
-1
Answered by 7 years ago
Edited 7 years ago

Just loop through every player and check for the player you want to teleport.

for i,v in pairs(game.Players:GetPlayers()) do
    if v.Name == game.Players.NAMEOFPLAYER then --V is the elements inside the table
            --do your normal teleport stuff
    end

end

Answer this question