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

How do i teleport all players to place?

Asked by 5 years ago
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

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

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)
0
I used getplayers for first time but didnt worked, but this one worked SunxLightz 30 — 5y
Ad
Log in to vote
0
Answered by
Cyrakohl 108
5 years ago

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

0
I made a typo woops on the comment near PlaceId didnt mean to put if woops Cyrakohl 108 — 5y

Answer this question