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

Help w/ 1 person per spawn?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

The script below is in ServerScriptService. What I am trying to do is I have 5 spawns in workspace and only 5 player can be in a server and 1 player has there own spawn. This is not working and I would love some help!

local spawns = {
    workspace.spawn1;
    workspace.spawn2;
    workspace.spawn3;
    workspace.spawn4;
    workspace.spawn5
};

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        if table.getn(spawns) > 0 then
            local randomSpawn = spawns[math.random(#spawns)]

            character.Torso.CFrame = randomSpawn.CFrame *
            CFrame.new(0,5,0)
        end
    end)
end)
1
Why are you using table.getn on one line, but the # operator on the next? funyun 958 — 8y
0
Wouldn't it be easier to just use teams if you want them to stick with a single spawn the whole game? BlueTaslem 18071 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Add a value for each spawn. When a player spawns onto that spawn the value = true so no one else can touch it.

Ad

Answer this question