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

Teleport to mapSpawn not working, why?

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

1 comment

0

You should use + instead of *

1 answer

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.

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