Help with spawning in the correct sequence?
I have 15 spawns in my game, each named "1" through "15", respectively, stored in a Folders object named SpawnLocations.
This is the corresponding code:
local REQUIRED_PLAYERS = 1
game.Players.PlayerAdded:Connect(function(player)
01 | for n, player in pairs (game.Players:GetPlayers()) do |
02 | local playerTable = { } |
05 | playerTable [ n ] = player |
09 | if game.Players.NumPlayers = = REQUIRED_PLAYERS then |
11 | player:LoadCharacter() |
12 | player.Character.PrimaryPart.Position = game.Workspace.SpawnLocations [ tostring (n) ] .Position |
end)
The problem that arises, is that when I go to test this via server, the player joins, but spawns at spawn #6, instead of spawn #1. Also, his head falls off.
I am unsure where the code in incorrect, but I'm willing to hear all suggestions.