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

How to use TS with tables properly?

Asked by 4 years ago
Edited 4 years ago

Hello, I am trying to make a party teleporter thing. Currently, it puts the player's name into a folder with a String Value. Sadly, I couldn't seem to get it work, any help is appreciated. Here is my current script;

local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")

local children = script.Parent.Folder:GetChildren()
for i = 1, #children do
    local child = children[i]
end

TeleportService:TeleportPartyAsync(000000000, children)

1 answer

Log in to vote
0
Answered by 4 years ago

The second argument of :TeleportPartyAsync() involves the player objects, not their names. You said the objects inside the folder are StringValues, with values of each player's name. The problem is that these are not player objects. To get the player objects, for example, you could run game.Players:GetPlayers(). I assume you do not want to teleport the whole server, though, so you'll have to determine how to get each player's object (since I can't see your whole set-up).

Anyways, here's an example, based on your code:

local Players = game:GetService("Players"):GetPlayers()
local TeleportService = game:GetService("TeleportService")

TeleportService:TeleportPartyAsync(000000000, Players)
Ad

Answer this question