Hello all! I have this script that is just really making me mad as its not working, But currently I think the problem is because players.playerremoving and humanoid.died are both firing before I even call them, which then causes an error and pauses the whole function. This is only my theory as I’m not able to test through the server and multiple players for some reason. If someone else can spot any other errors that would be greatly appreciated
local minPlayerCount = 2
local repStorage = game.ReplicatedStorage
local inGame = repStorage.inGame
local intermissionTime = 10
local intervalTime = 100
local spinner = game.Workspace.spinner
local Players = game:GetService("Players")
local currentPlayers = {}
local removeplayers = function (player)
print(player.Name.." died")
table.remove(currentPlayers, table.find(currentPlayers, player))
if #currentPlayers:GetChildren() <= 1 then
inGame.Value = false
player.Character.HumanoidRootPart.CFrame = game.Workspace.SpawnLocation.CFrame + Vector3.new(0,5,0)
end
end
Players.PlayerRemoving:Connect(removeplayers())
while true do
wait(5)
local multi = 1
if #Players:GetChildren() >= minPlayerCount then
inGame.Value = true
for i,v in pairs(Players:GetChildren()) do
table.insert(currentPlayers,i,v)
v.Character.HumanoidRootPart.CFrame = game.Workspace.startPos.CFrame
v.Character.Humanoid.Died:Connect(removeplayers())
end
if inGame.Value == true then
for i = intermissionTime, 1, -1 do
repStorage.gameStatus.Value = "Time remaining in intermission: "..i
wait(1)
end
while inGame.Value == true do
for i = intervalTime, 1, -1 do
spinner.CFrame = spinner.CFrame*CFrame.fromEulerAnglesXYZ(0,(0.1*multi),0)
wait(.01)
end
local multi = multi*5
end
end
end
end