So I have this game I'm designing for fun, nothing serious, and the scripting part required teleporting a player using a script. I looked online, and the only tutorials were if the player touched or clicked a part. I need to be able to use a script to teleport the player. If possible, using their name. If you know any tutorials/links on it that works too.
COMMUNITY QUESTION
Is it possible to teleport a player with a script? Local or Server?
3 answers
Hey! This would be able to teleport the player, and if you need help getting the players name in the script just let me know!
workspace.playername.HumanoidRootPart.Position = Vector3.new(0, 0, 0)
or, if you wanted to teleport them to another part you could do
workspace.playername.HumanoidRootPart.Position = workspace.Part.position
Hope this helps!
Alright so you'll need to put this into a global script inside ServerScriptService and everything will work good, inform me if there's any error
local allowedPlayers = {"CYP3RBOT", "RandomName", "RandomName1", "RandomName2"} -- This is a table of the players that will be teleported
game.Players.PlayerAdded:Connect(function(player)
for i, v in pairs(allowedPlayers) do
if player.Name == v then
player.Character.HumanoidRootPart.Position = workspace.Part.Position -- Change "Part" into the name of the part you wanna teleport the player to
end
end
end)
server script
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
game.Workspace.part.Touched:Connect(function() -- part to touch
character:MoveTo(Vector3.new(0,0,0)) -- position to move to
end)
end)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
when do you want someone to teleport?