Answered by
5 years ago Edited 5 years ago
Assuming you are asking for a full tutorial on how to teleport multiple players to another place in the same game, I am here to give you the full tutorial.
Theoretically, you could teleport multiple players with things other than a part, but for simplicity, this will be using a part to teleport multiple players.
What you want to do is create a Part in Workspace. You can do whatever you want to this part, as long as multiple players are able to touch this part. After you have placed the part in Workspace, place a Script inside the part.
Inside the script, the code should look something like this:
01 | local Players = game.Players |
02 | local PlayersTouching = { } |
04 | local NeededPlayers = 1 |
07 | local Toucher = script.Parent |
08 | local RunService = game:GetService( "RunService" ) |
09 | local TeleportService = game:GetService( "TeleportService" ) |
12 | if obj.Parent:IsA( "Model" ) and obj.Parent:findFirstChild( "Humanoid" ) then |
13 | if Players:GetPlayerFromCharacter(obj.Parent) ~ = nil then |
21 | function TeleportPlayers() |
22 | local PrivateServerId = TeleportService:ReserveServer(PlaceId) |
23 | TeleportService:TeleportToPrivateServer(PlaceId, PrivateServerId, PlayersTouching) |
26 | Toucher.Touched:connect( function (obj) |
28 | local CurChar = obj.Parent |
29 | local CurPlayer = Players:GetPlayerFromCharacter(CurChar) |
32 | for i,v in pairs (PlayersTouching) do |
33 | if v = = CurPlayer then |
39 | table.insert(PlayersTouching, CurPlayer) |
45 | Toucher.TouchEnded:connect( function (obj) |
47 | local CurChar = obj.Parent |
48 | local CurPlayer = Players:GetPlayerFromCharacter(CurChar) |
51 | for i,v in pairs (PlayersTouching) do |
52 | if v = = CurPlayer then |
58 | table.remove(PlayersTouching, index) |
64 | local TimerRunning = false |
66 | local LastTick = tick() |
67 | RunService.Stepped:connect( function () |
68 | if #PlayersTouching > = NeededPlayers then |
76 | CurTime = CurTime-(tick()-LastTick) |
85 | for i,v in pairs (PlayersTouching) do print (v.Name) end |
Extra advice: In order to make sure that the Toucher.TouchEnded
event does not fire when it is not needed to fire, it is important to make sure that the Part that was placed in Workspace is not collidable, anchored, transparent, and touches all parts of the Character. This can be done by creating a very large part that covers a lot of area.
I hope that helps! :D