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

Teleport the rest?

I have this code:

while game.Players.NumPlayers < 1 do
	    wait()
	end 
local Players = game.Players:GetPlayers()
local Phantom = Players[math.random(#Players)]
target = Vector3.new(45, 17.5, -27)
Phantom.Character.Torso.CFrame = CFrame.new(target)

That teleports 1 random player? How would i teleport the rest?

else
target = Vector3.new(45, 17.5, -20)
Phantom.Character.Torso.CFrame = CFrame.new(target)

This doesnt work. Please help! Thanks for reading

2 answers

create a for loop that loops through all the players and puts them at that position one by one. The Vector 3 part puts every player on top of each other at that spot, you can edit the CFrame value to (i*5,0,0) if you want a row of players. Then, you need to check if the player is the name of the chosen phantom, if it isn't, teleport the player, else teleport the phantom

local Players = game.Players:GetPlayers()
local target = Vector3.new(45, 17.5, -27)

--Pick a phantom
local phantom = game.Players.PlayerName

for _,i in pairs(Players) do
	if not(i.Name == phantom) then
		i.Torso.Position = target * Vector3.new(0,i*5,0)
	else
		--teleport phantom
end

1 comment

0

yes, thats good, but would also move the phantom

while game.Players.NumPlayers < 1 do
        wait()
    end 
local Players = game.Players:GetPlayers()
target = Vector3.new(45, 17.5, -27)
for i,v in pairs(Players) do
	v.Character.Torso.CFrame = CFrame.new(target)
end

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