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

Why are people not teleporting?

Asked by 9 years ago

I need this to teleport others to this location but its not working. I also need it so that it will teleport after 30 seconds and repeat this continuously.

game.Players.Character:MoveTo(Vector3.new(123, 0.59, -34))

3 answers

Log in to vote
1
Answered by 9 years ago

My best guess as to teleporting all the players to that location would be to use a generic for loop. Generic fors go through all values in a table. So basically we need to get all the children in Players, get their characters and move them to that location. So it would look like this...

wait() --You can remove this if you want, but it's better if it's there
for i,v in pairs(game.Players:GetChildren()) do
    v.Character:MoveTo(Vector3.new(123, 0.59, -34))
end

And if you wanted to do that every 30 seconds, you would use a while loop, like this:

while true do --Makes an infinite loop
wait()
for i,v in pairs(game.Players:GetChildren()) do
    v.Character:MoveTo(Vector3.new(123, 0.59, -34))
end
wait(30)
end

Hope this helped.

Ad
Log in to vote
1
Answered by 9 years ago

"Players"

e = game.Players:GetChildren()
 t = e.Character
--First of all you need to define "players" If you want 1 player or all players, I won't gaurantee this will work
game.Players.PlayerAdded:connect(function()
if t ~= nil then then
for i = 1, #e do
t:MoveTo(Vector3.new(123,0.59,34))
elseif t == nil then
return
  end
 end
end)
0
This might work on a lot of players, if you just want 1 to teleport. Remove the s from Players? PlatinumLocks 50 — 9y
0
Does not work Opptitronica 0 — 9y
0
mmk PlatinumLocks 50 — 9y
0
I edited it, try that one , By the way it won't loop, just begin when a player is added. PlatinumLocks 50 — 9y
Log in to vote
0
Answered by 9 years ago

easy.

function teleport(player,position)
if player.Character:FindFirstChild("Torso") then
player.Character.Torso.CFrame = CFrame.new(position) -- assuming the position is Vector3
end
end

function teleportAll(people,position)
for i,v in pairs(people) do
teleport(v,position) -- possibly a randomized position, or it would cause alot of people in one spot.
end
end

while wait() do
wait(30) -- intermission
teleportAll(game.Players:GetChildren(),Vector3.new(0,10,0))
wait(3) -- choose random player
local peeps = game.Players:GetChildren()
teleport(peeps[math.random(1,#peeps)],Vector3.new(0,10,20))
end

This is all relatively easy scripting. I prefer using torso.CFrame than MoveTo() because with CFrame you can be precise.

Answer this question