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

Is it possible to teleport a player with a script? Local or Server?

Asked by 3 years ago

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.

0
when do you want someone to teleport? OfficerBrah 494 — 3y

3 answers

Log in to vote
0
Answered by
emervise 123
3 years ago

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!

Ad
Log in to vote
0
Answered by 3 years ago

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)
Log in to vote
0
Answered by 3 years ago

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)

Answer this question