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

How to teleport players?

Asked by
7777ert 49
3 years ago

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.

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. 7777ert 49 — 3y

3 answers

Log in to vote
2
Answered by 3 years ago

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.

0
thanks! your code works fine! 7777ert 49 — 3y
Ad
Log in to vote
1
Answered by 3 years ago

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
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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!

Answer this question