Basically, I want to make a L4D concept. Everyone is in the lobby, upon game start all players are put on team 'Players' and warped to the map . On death, they are placed back in 'Lobby'. But my script doesn't recognize when everyone has died, not resetting the game, and leaving everyone trapped in 'Lobby'.
local start = Instance.new("Hint")
start.Parent = game.Workspace
start.Text = "Starting Game."
wait(1)
start.Text = "Starting Game.."
wait(1)
start.Text = "Starting Game..."
wait(1)
start.Text = "Starting Game."
wait(1)
start.Text = "Starting Game.."
wait(1)
start.Text = "Starting Game..."
wait(1)
while true do
local start = 10
local hint = Instance.new("Hint")
hint.Parent = game.Workspace
for i = 1,start do
hint.Text = start - i
wait(1)
end
hint.Text = "Starting Game."
wait(2)
hint:remove()
function setTeam(player, teamName)
player.TeamColor = game.Teams[teamName].TeamColor
if player.Character then
player:LoadCharacter()
end
end
for _, player in pairs(game.Players:GetPlayers()) do
setTeam(player, "Players")
end
target = CFrame.new(10, 0.5, 10)
for i, player in pairs(game.Players:GetChildren()) do
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
The script to change team upon death:
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
repeat wait() until Character:FindFirstChild("Humanoid") ~= nil
Character.Humanoid.Died:connect(function()
if Player.TeamColor == game.Teams.Players.TeamColor then
Player.TeamColor = game.Teams.Lobby.TeamColor
end
end)
end)
end)

1 comment
i have the same problem, have you figured out how to restart the workspace. or reset the game?