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

How can you teleport all players to a Certain Area?

Asked by 3 years ago

I have been thinking of this for a long time... How can you teleport all players to a certain area?

No matter how much I try to research, I cant find anything. So I decided to come on this site to ask a question.

1 answer

Log in to vote
2
Answered by 3 years ago

Assuming you meant teleport within a place, there is an article made by roblox.

You'll need to get all players first, using game.Players:GetPlayers().

local plrs = game.Players:GetPlayers()

Next, teleport players to the area. We can do this using SetPrimaryPartCFrame.

Player's character have primarypart on itself already, so we can just use that on characters. We'll check if character exists just in case.

Use for loop because we want every player to be teleported.

for index, plr in pairs(plrs) do
    if plr.Character then --check for player character
        plr.Character:SetPrimaryPartCFrame(CFrame.new(0, 0, 0)) --replace the numbers in CFrame with the position you want
    end
end

The code should look like this now:

local plrs = game.Players:GetPlayers()
for index, plr in pairs(plrs) do
    if plr.Character then
        plr.Character:SetPrimaryPartCFrame(CFrame.new(0, 0, 0))
    end
end
0
Thanks :) Finty_james 269 — 3y
Ad

Answer this question