Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i teleport all players to place?

local plr = game.Players.LocalPlayer

local plrlist = game.Players:GetChildren()

  

local placeid = 2962165468

  

game.Workspace.KingCrab.Humanoid.Died:Connect(function()

wait(5)

for i = 1,#plrlist do

game:GetService("TeleportService"):Teleport(placeid, plr[plrlist])

end

end)

Not works what do i need to do

2 answers

✓ Accepted answer

You can't teleport other players with a LocalScript. You need to use a server script to do that.

Btw use Players:GetPlayers() instead of Players:GetChildren()

`workspace.KingCrab.Humanoid.Died:Connect(function()
    wait(5)
    for i,v in pairs(game.Players:GetPlayers()) do
	    game:GetService("TeleportService"):Teleport(v, 2962165468)
    end
end)

1 comment

0

I used getplayers for first time but didnt worked, but this one worked

First of all you do not use a local script to teleport people as that will not work as TeleportService can only be called on the server and not the client.

Second of all i suggest using pairs when iterating through a table personally.

But i will happily write an example for you to follow.

This needs to be put into a server script:


local PlaceId = nil -- Change this to a place if of your choice
local Players = game.Players:GetPlayers() 
local TeleportService = game:GetService("TeleportService")

for I,Players in pairs(Players) do 
TeleportService:Teleport(PlaceId,v)
end



1 comment

0

I made a typo woops on the comment near PlaceId didnt mean to put if woops

This discussion is preserved as it was. New answers, comments, and votes are closed.