Hello everyone!
I am attempting to create an elevator that teleports a specific group of players, like in the game Tower Defense Simulator or most story games. However, I am having a bit of trouble.
Here, I am trying to select only the players that I want. When tested, it prints the correct player names and gives no errors. I think it is functioning exactly how I want it to.
local readyPlayers = {}
local plrs = game.Players:GetChildren()
for i = 1, #plrs do
if plrs[i].Ready.Value == 1 then
table.insert(readyPlayers,1,plrs[i].Name)
end
end
Here is the actual teleport script:
local service = game:GetService("TeleportService")
local server = service:ReserveServer(12345678)
service:TeleportToPrivateServer(12345678,server,plrs)
When this is ran, it gives the error "Unable to cast value to object." If I change the line to below, it works, but I want it to only be certain players and not everyone.
local players = game.Players:GetChildren()
service:TeleportToPrivateServer(12345678,server,players)
Does anyone know how to fix the error? Thank you for reading through all of this :)
