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

Im trying to teleport a group of players in a table to a spot within the game can someone help?

Asked by 5 years ago

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.

0
Did you try using CFrame? Zikelah 20 — 5y
0
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 Splixent 0 — 5y

2 answers

Log in to vote
0
Answered by
Zikelah 20
5 years ago
--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
0
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. Splixent 0 — 5y
0
Do I put this in the union/part I want the players to touch to teleport? If so, LocalScript or Script? sugarshanked 0 — 5y
Ad
Log in to vote
0
Answered by
Yuuwa0519 197
5 years ago
Edited 5 years ago

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

Answer this question