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

How do I Make a Teleport To Another Place?

Asked by 7 years ago

I want to make a teleport for when you touch a brick that it teleports you to my friends place. Please help! (Also It Isn't To Get Him Visits We just Want To Reduce Lag In My Game)

2 answers

Log in to vote
0
Answered by
korj5 0
7 years ago

Here script, change the ID of your friend's place's id.

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
    game:GetService("TeleportService"):TeleportToSpawnByName(*IDHERE*, "Your friend's place's spawnname", player)
    end
end

script.Parent.Touched:connect(onTouched)

0
Your welcome and if its work please accept the answer :D korj5 0 — 7y
0
Thanks! Helped a ton! RisingRainbowPuppy65 0 — 7y
Ad
Log in to vote
-1
Answered by 7 years ago
Edited 7 years ago

Here is a great wiki article that can help you.

But here is my interpretation:

local teleportid = 0 --Put the place ID here
local player = "Telamon" --put which player to teleport
game:GetService('TeleportService'):Teleport(teleportid, game.Players:FindFirstChild(player))

However, if you want it to teleport everyone in the game, here is the proper code:

local teleportid = 0 --Put the place ID here
for i,v in pairs(game.Players:GetPlayers()) do
game:GetService('TeleportService'):Teleport(teleportid, v)
end

Lastly, if you want it where everytime someone joins, it teleports them, here is how it would go:

local teleportid = 0 --Put the place ID here
game.Players.PlayerAdded:connect(function(plr)
game:GetService('TeleportService'):Teleport(teleportid, plr)
end)

Hope that helped!

Answer this question