local alivePlayers = { }
local spawnPoints = { }
local connection
local giveDelay = 2
function look(player)
for i,v in pairs(alivePlayers) do
if player.UserId == v.UserId then
return true
end
end
return false
end
function printAllSpawns()
for i,v in ipairs(spawnPoints) do
print(v.Name, i)
end
end
function findOpenSpawn(player)
for i,v in ipairs(spawnPoints) do
local doorSettings = v:FindFirstChild("SpawnSettings")
if doorSettings then
local Lastused = doorSettings:FindFirstChild("LastUsed")
local Cooldown = doorSettings:FindFirstChild("Cooldown")
if Lastused.Value ~= 0 then
print(Lastused.Value)
print(Cooldown.Value)
if Lastused.Value + Cooldown.Value <= os.time() then
print("spawning "..player.Name)
Lastused.Value = os.time()
print(Lastused.Value + Cooldown.Value)
print(os.time())
print(v.Name)
table.insert(alivePlayers, player)
player.Character:SetPrimaryPartCFrame(v.CFrame)
game:GetService("ReplicatedStorage").SpawnPlayer:FireClient(player)
return true
else
return false
end
else
print("0")
print("spawning "..player.Name)
Lastused.Value = os.time()
table.insert(alivePlayers, player)
player.Character:SetPrimaryPartCFrame(v.CFrame)
game:GetService("ReplicatedStorage").SpawnPlayer:FireClient(player)
return true
end
end
end
end
for i,v in pairs(game.Workspace:GetChildren()) do
if v:FindFirstChild("SpawnSettings") then
print(v.Name, i)
table.insert(spawnPoints, v)
v.Transparency = 1
end
end
while wait(2) do
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
if not look(v) then
local success = findOpenSpawn(v)
if success then
print("Successful.")
local char = v.Character
local humanoid = char:FindFirstChild("Humanoid")
if not humanoid then
while not humanoid do
wait(.1)
humanoid = char:FindFirstChild("Humanoid")
if humanoid then
break
end
end
end
print("Connection established.")
connection = humanoid.Died:Connect(function()
wait(game.Players.RespawnTime)
table.remove(alivePlayers, i)
print("removed "..v.Name)
connection:Disconnect()
end)
end
end
end
end
At the current moment, it appears to only be trying to spawn everyone at one spawn point and skips over all the rest. I believe the issue is with the for loop, but I’m not sure.