I'm trying to teleport players that are inside of a table to another location within the game, i need there to be at least 4 players in the table for the count down to start. I'm not trying to teleport the group of players to another game i'm trying to teleport the group of players to a different spot in the game.
Im trying to teleport a group of players in a table to a spot within the game can someone help?
2 answers
--This is how you would teleport a player using CFrame, in the simplest way
local Teleportto = --the path to the part you want to teleport to
local from = script.Parent -- this is just fo example
local function TeleportToPosition(part)
local hum = part.Parent:FindFirstChild("HumanoidRootPart")
--HumanoidRootPart is the thing we want to teleport
if hum then
hum.CFrame = Teleportto.CFrame + Vector3.new(0,5,0)
end
end
-- I am going to use a Touched event for this
from.Touched:Connect(TeleportToPosition)
--That would be how you teleport players
2 comments
Im trying to teleport a group of 8 players in a table using tables like this: local PlayersToTeleport = {}. inside the {} contains the players that will be teleported. I already know how to add them to the table but i want to teleport the group of them to the same spot. Using CFrame, yes i know but i dont know how to teleport the table of players.
Do I put this in the union/part I want the players to touch to teleport? If so, LocalScript or Script?
I think if you are trying to wait for certain players and teleport you can use this.
First, I think you can wait until the table is storing more than 4 value.
local table = {}
local teleportLocation = CFrame.new(--Copy the position CFrame by placing the brick to your desired position and type in commandbar this : print(workspace.Part.CFrame))
local function checkPlayers()
if #table >=4 then
return true
else
return false
end
end
--This code Will Check If number of Players Stored In Table if over or equal to 4.
Then, make a event that inserts new player into table.
--The event Fires(Like the part was touched. If you want to make Gui that registers player, you will also have to use remote events to tell server script that the player is willing to enter a teleport.)
part.Touched:Connect(function(plr)
if plr:FindFirstChild("Humanoid") then--Checks if the thing that touched the part is actually a player.
table.insert(table, 1, plr)
end
end
Now, you would want to make a script that fires as soon as the player ready to teleport is over 4.
while wait(5) do -- I just like to make the script wait 5 seconds so it`s less laggy then checking every milliseconds
if checkPlayers then
--do Count Down Maybe? Its up To you.
for _, value in pairs (table) do --You should learn how for loops work to understand better if you don't already, but I will tell you anyways. This basically goes through every value in table. _ and v can be changed to any names, since it`s a variable.
local teleportMainPart = v:FindFirstChild("Head")
teleportMainPart.CFrame = teleportLocation
end
end
end
I think this codes should work if I didn`t mistake. Hope It helps :D
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Did you try using CFrame?
I know that i would have to use CFrane but i dont know how to get the specific group of players that are within a table to teleport. Instead of the whole server