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

How to move players on or around the block?

Asked by 10 years ago
        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

Log in to vote
0
Answered by
trogyssy 221 Moderation Voter
10 years ago

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

Ad
Log in to vote
-1
Answered by
Tesouro 407 Moderation Voter
10 years ago

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).

0
Have enough spawns for every player in the server. Tesouro 407 — 10y

Answer this question