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

Teleport to mapSpawn not working, why?

Asked by
Nidoxs 190
8 years ago

I want all players to teleport to the bricks position but add an offset at the same time so they don't collide and fling.

for i, v in pairs(game.Players:GetChildren())do
        v.Character:MoveTo(selectedMap.MapSpawn.Position * Vector3.new(math.random(-5,5),0,math.random(-5,5)))
    end
0
You should use + instead of * LetThereBeCode 360 — 8y

1 answer

Log in to vote
0
Answered by
R_alatch 394 Moderation Voter
8 years ago

I suggest not teleporting all players to one brick, rather than you just teleporting them to an individual brick. To do this, simply make a variable named "spawns", or "Spawns". Then, use the i part of your loop to teleport them into each spawn. Also, name the group of spawns you create "Spawns".

local spawns = selectedMap:FindFirstChild("Spawns"):GetChildren()

for i, v in pairs(game.Players:GetChildren()) do
    v.Character:MoveTo(spawns[i].Position)
end

Above is the code; it pretty much makes a variable that gets all the spawns, then making a loop, and last teleporting each player to a spawn using the i part of the loop. Also, something to note is that you don't need the exact amount of spawns of players in the server, just make sure you have enough to that each player gets a spawn, otherwise it will error.

Ad

Answer this question