i just noticed a bug just now where when the game is still going on and if the player dies the player goes back to lobby but i dont want that to happen as i want it to respawn back in the map how would i do that
local status = game:GetService("ReplicatedStorage"):FindFirstChild("Status")
local maps = game.Workspace.Maps:GetChildren()
local interTime = 10 --Intermission Time
local roundTime = 420
local PlayerNeeded = 1
while true do wait()
if #game:GetService("Players"):GetPlayers() >= PlayerNeeded then
local formerroundtime = roundTime
local formerintertime = interTime
while true do --intermission loop
status.Value = "Intermission:"..interTime
if interTime > 0 then
interTime = interTime - 1
end
wait(1)
if interTime <= 0 then
interTime = formerintertime
break
end
end
wait()
status.Value = "Round Starting.."
wait(3)
local chosenMapNumber = math.random(1,#maps)--picks a random map
local chosenMap = maps[chosenMapNumber]
local TpRed = chosenMap.Spawns.RedSpawns:GetChildren()
local TpBlue = chosenMap.Spawns.BlueSpawns:GetChildren()
for i, player in pairs(game.Players:GetChildren()) do
local char = player.Character
if player.TeamColor == BrickColor.new("Really red") then
print("red team")
local tool = game.ServerStorage.Tools:GetChildren()
local random = tool[math.random(1,#tool)]
local cloned = random:Clone()
cloned.Parent = player.Backpack
char:WaitForChild("Humanoid"):EquipTool(cloned)
char.HumanoidRootPart.CFrame = TpRed[math.random(1,#TpRed)].CFrame * CFrame.new(0,3,0)
elseif player.TeamColor == BrickColor.new("Really blue") then
print("blue team")
local tool = game.ServerStorage.Tools:GetChildren()
local random = tool[math.random(1,#tool)]
local cloned = random:Clone()
cloned.Parent = player.Backpack
char:WaitForChild("Humanoid"):EquipTool(cloned)
char.HumanoidRootPart.CFrame = TpBlue[math.random(1,#TpBlue)].CFrame * CFrame.new(0,3,0)
end
end
while true do --round loop
status.Value = "Game:"..roundTime
roundTime = roundTime - 1
wait(1)
if roundTime <= 0 then
roundTime = formerroundtime
break
end
end
for i, player in pairs(game.Players:GetChildren()) do
player.Character:WaitForChild("Humanoid"):UnequipTools()
player.Backpack:FindFirstChildOfClass("Tool"):Destroy()
if player.Character:FindFirstChildOfClass("Tool") then
player.Character:FindFirstChildOfClass("Tool"):Destroy()
end
end
wait()
status.Value = "Round Ended!"
wait(3)
for i, player in pairs(game.Players:GetChildren()) do
player.leaderstats.Cash.Value += 70
player:LoadCharacter()
end
else
print("not enough!")
end
end
need help im desperate