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
7 years ago
function onChatted(msg, recipient, speaker) 

local source = string.lower(speaker.Name) 

msg = string.lower(msg) 

if (msg == "tp") then 

game.Workspace.Player1.HumanoidRootPart.CFrame = CFrame.new(-1899.747, 492.098, -95.816)

end

end 

function onPlayerEntered(newPlayer) 
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end 

game.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:

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

speaker.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 — 7y
0
speaker.Character should have worked. cabbler 1942 — 7y

2 answers

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

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

If this worked please accept the answer

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

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

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

Answer this question