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

How to teleport players?

Uh so i tried to teleport players before and it works fine. But for some reason it is not working today. Here is my code:

wait(10)
for i,v in pairs(game.Players:GetPlayers()) do
	v.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(3,3,3)
end
print("done")

It prints 'done' without teleporting the player. I have no idea what happened. Anybody can solve this? Thanks.

1 comment

0

ok so i just figured out why my code is not working... its because im teleporting my humanoid to 3,3,3 from 0,0,0. Since im testing this on a baseplate, i cant see any differences when the script teleported my character. i changed the destination to 100,100,100 and it works fine.

3 answers

✓ Accepted answer

I think you should use this:

local Players = game:GetService("Players")

for i, plrs in pairs(Players:GetPlayers()) do
	plrs.Character:SetPrimaryPartCFrame(CFrame.new(YOURPOS))
end

YOURPOS is the vector3value or CFrame value that is gonna be inputted. Replace the YOURPOS with a value or make it a variable with that value. Hope this works and if this one doesn't follow the one above mine.

1 comment

0

thanks! your code works fine!

Try this:

local s = script.Stat
t = 0
while true do
       t = 15
       repeat
               t = t-1
               s.Value = “Intermission.. “..t
               wait(1)
          until t == 0
          s.Value = “Game starting!”
          wait(2)
          local plrs = game.Players:GetChildren()
          for i = 1, #plrs do
               local num = math.random(1,32)
               plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports[“Part”..num].Position)
         end
         t=100
         repeat
                 t = t-1
                 s.Value = t..” seconds left”
                 wait(1)
            until t ==0
end

I think you should replace CFrame with Vector3, like this:

wait(10)

for i,v in pairs(game.Players:GetPlayers()) do
    v.Character:WaitForChild("HumanoidRootPart").CFrame = Vector3.new(POSITION)
end

print("done")

(Remember to replace "POSITION" with the position that you want to teleport the players.)

Good luck!

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