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

How to move players on or around the block?

		spawns = mapChosenClone.Spawns:GetChildren()
	
		for i,v in pairs(game.Players:GetPlayers()) do
    		name = v.Name
			check = game.Workspace:FindFirstChild(name)
			if check then
				checkHumanoid = check:FindFirstChild("Humanoid")
				if checkHumanoid then
					check:MoveTo(spawns[i].Position)
				end
			end
		end

How can I get the check:MoveTo(spawns[i].Position) so that instead of taking them to that block, it takes the to the block, OR around the block. Right now each player needs its own spawn. How can I get it to spawns Every player to that one spawn and spawns them around the spawn. Maybe something like Vector3 or CFrame

2 answers

✓ Accepted answer

His issue is that he only wants one spawn, but the issue is that players teleport into each other.

math.randomseed(tick())

local spawn=               --Define the spawn here
local locations={spawn.Position, 
(spawn.Position+Vector3.new(5, 0, 5)),
(spawn.Position+Vector3.new(5, 0, 0)), 
(spawn.Position+Vector3.new(0, 0, 5)), 
(spawn.Position+Vector3.new(-5, 0, -5)), 
(spawn.Position+Vector3.new(0, 0, -5)), 
(spawn.Position+Vector3.new(0, 0, -5)), 
(spawn.Position+Vector3.new(5, 0, -5)), 
(spawn.Position+Vector3.new(-5, 0, 5)), 
(spawn.Position+Vector3.new(5, 5, 5)), 
(spawn.Position+Vector3.new(0, 5, 0)), 
(spawn.Position+Vector3.new(5, 5, -5)), 
(spawn.Position+Vector3.new(-5, 5, 5)), 
(spawn.Position+Vector3.new(5, 5, 0)), 
(spawn.Position+Vector3.new(0, 5, 5)), 
(spawn.Position+Vector3.new(-5, 5, -5)), 
(spawn.Position+Vector3.new(0, 5, -5)), 
(spawn.Position+Vector3.new(-5, 5, 0))} --Here ya go, eighteen locations around and on your spawn

local whereto=locations--A placeholder that we'll use to ensure no one spawns in the same place as someone else
for i,v in pairs(game.Players:GetPlayers()) do
    local place=math.random(1, #whereto)
    v.Character:MoveTo(whereto[place])
    table.remove(whereto, place)
end
whereto=locations

Is all that check mess to find the character? Well... What about:

for i,v in pairs(game.Players:GetPlayers()) do
	char = v.Character

One of your problems is solved. But I don't get exactly what you meant in that question. Each player has their spawn, they have to be different? If players need to spawn in different spawns, I suggest you to rename them numbered, like "Spawn1".

for i,v in pairs(game.Players:GetPlayers()) do
	char = v.Character
	spawn = mapChosenClone.Spawns:FindFirstChild("Spawn" .. tostring(i))
	char:MoveTo(spawn.Position)
end

If each player has a specific spawn, try using Teams or identifying their spawns (using their names, for example).

1 comment

0

Have enough spawns for every player in the server.

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