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

How to teleport any player?

Asked by
truted1 21
8 years ago
01function onChatted(msg, recipient, speaker)
02 
03local source = string.lower(speaker.Name)
04 
05msg = string.lower(msg)
06 
07if (msg == "tp") then
08 
09game.Workspace.Player1.HumanoidRootPart.CFrame = CFrame.new(-1899.747, 492.098, -95.816)
10 
11end
12 
13end
14 
15function onPlayerEntered(newPlayer)
16newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
17end
18 
19game.Players.ChildAdded:connect(onPlayerEntered)

Hello, I was wondering how to make this script work for all players. Right now it only teleport Player1. I tried lots of things and they do not work. For example:

1recipient.Character.HumanoidRootPart.CFrame = CFrame.new(-1899.747, 492.098, -95.816)
1speaker.Character.HumanoidRootPart.CFrame = CFrame.new(-1899.747, 492.098, -95.816)

Is there a special tag for a player or something?

Thanks.

0
Check this out. Let me know if you need any clarification! http://wiki.roblox.com/index.php?title=Teleportation Shiro75 0 — 8y
0
speaker.Character should have worked. cabbler 1942 — 8y

2 answers

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

To teleport every player you should iterate over all the players and then teleport them - though idk why you would want this since this would teleport all players to a certain location.

1for i,v in pairs(game.Players:GetChildren()) do
2-- do your teleporation script and btw v is the player so v.Character.Torso
3end

If this worked please accept the answer

Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

This is a script that I am currently using for a game with multiple maps. Hope this works!

1p = game.Players:GetChildren() -- Get Players
2for i= 1, #p do            
3    p[i].Character.Torso.CFrame = CFrame.new(X, Y, Z) -- Position
4end

Answer this question