Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to teleport any player?

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.

2 comments

0

Check this out. Let me know if you need any clarification! http://wiki.roblox.com/index.php?title=Teleportation

0

speaker.Character should have worked.

2 answers

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.