Hello,
So I am trying to script a round system where you have to escape before you get caught by the killer.
I am trying to make it so that if the killer leaves it will reset everyone and start the lobby function again to start a new round. For some reason it seems like it goes to the lobby function fire it but do none of the stuff in it. It also kills me twice when it should only once.
I am fixing the script for someone so not totaly sure and really confused on why it is not working.
Script:
function LobbyLoop()
local InLobby = true
while InLobby do
if #players:GetChildren() < PlayersRequiredToStart then
wait()
status.Value = "There's Not Enough People To Start"
else
repeat wait(1)
CurrentTimer = CurrentTimer - 1
status.Value = "Intermission: "..CurrentTimer.." Seconds"
until CurrentTimer <= 0
if CurrentTimer <= 0 then
PlayersInGame = GetPlayerList()
Killer = RandomPlayer(PlayersInGame)
KillerRemove()
PlayersInGame = Survivors
InLobby = false
StartLoop()
end
end
end
end
function StartLoop()
GameOn = true
if GameOn == true then
TeleportPlayerTo(Killer,(SpawnK))
Killer.Backpack.Flashlight:Destroy()
AddTool(Knife, Killer)
print(PlayersInGame)
local RandomSpawn = SpawnS[math.random(1, #SpawnS)]
for i, plr in pairs(game.Players:GetChildren()) do
if plr ~= Killer then
plr.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
end
end
GameLoop()
end
end
local KillerOut = false
function GameLoop()
GameOn = true
GameTimer = GameTime
while true do
wait(1)
GameTimer = GameTimer - 1
status.Value = "Time left: " ..GameTimer.. " Seconds"
if GameTimer <= 0 then
print("Send end stuff")
else if KillerOut == true then
status.Value = "Killer left the server, restarting the game."
wait(5)
GameOn = false
Killer = nil
print("Before kill")
for i, plr in pairs(game.Players:GetChildren()) do
plr.Character.Humanoid.Health = 0
end
game.Workspace.Maps.AbandonedHighSchool.ToolSpawns:Destroy()
local ToolClone = game.ServerStorage.ToolSpawns
ToolClone.Parent = game.Workspace
print("Before loop")
LobbyLoop()
print("After loop")
break
end
end
end
end
