Here's the long script i made myself.
It essentially is a while loop, and will continuously run whilst some booleans are set to true.
Now, i can't seem to figure out on how i could manage to have it so when the killer dies, which i made it so we can access the killer within a variable, how would i end the game?
wait(6) -- Making sure everything loads!
-- SERVICES --
local Players = game:GetService("Players")
-- VARIABLES --
local Game_Is_ON = true -- IMPORTANT | THIS NEEDS TO BE SET TRUE
local isGameAvailable = true -- IMPORTANT | THIS NEEDS TO BE SET TRUE
local intermissionTime = 5
local roundInProgressTime = 15
local displayGameState = game.StarterGui.MainGui.DisplayGameState
local gameLocation = game.Workspace.GameLocation
local lobbyLocation = game.Workspace.LobbyLocation
local stringDisplaysment = game.StarterGui.StringDisplaysment
local hasGameStarted = game.StarterGui.HasGameStarted
local classicSword = game.ReplicatedStorage.ClassicSword
local newClassicSword = nil
local gameIsAllowedToContinue = true
newRandomKiller = nil
-- FUNCTIONS --
local function intermissionBreak()
for i = intermissionTime,0,-1 do
wait(1)
print("Intermission : "..i)
displayGameState.Text = "Intermission : "..i
end
end
local function roundInProgress()
for i = roundInProgressTime,0,-1 do
if gameIsAllowedToContinue == true then
wait(1)
print("Round In Progress : "..i)
displayGameState.Text = "Round In Progress : "..i
end
end
end
local function teleportPlayersToGame()
for i, v in pairs(Players:GetPlayers()) do
if v.Character and v.Character.HumanoidRootPart.Position then
v.Character.HumanoidRootPart.Position = gameLocation.Position
end
end
end
local function teleportPlayersToLobby()
for i, v in pairs(Players:GetPlayers()) do
if v.Character and v.Character.HumanoidRootPart.Position then
v.Character.HumanoidRootPart.Position = lobbyLocation.Position
end
end
end
local function notEnoughPlayers()
displayGameState.Text = math.abs(#Players:GetChildren() - 4).." more players are needed to start the game!"
print(math.abs(#Players:GetChildren() - 4).." more players are needed to start the game!")
end
local function applyingToStringValue()
while wait() do
stringDisplaysment.Value = displayGameState.Text
end
end
spawn(applyingToStringValue)
-- GAME HANDLER --
hasGameStarted.Changed:Connect(function(newValue)
if newValue == true then
newRandomKiller = Players:GetPlayers()[math.random(1,#Players:GetPlayers())]
print("The killer is : "..newRandomKiller.Name)
newRandomKiller.isKiller.Value = true
newRandomKiller.PlayerGui.MainGui.KillerText.Visible = true
newClassicSword = classicSword:Clone()
newClassicSword.Parent = newRandomKiller.Backpack
for i, v in pairs(Players:GetPlayers()) do
if v.isKiller.Value == false then
v.PlayerGui.MainGui.SurvivorText.Visible = true
end
end
elseif newValue == false then
print("Game Ended!")
newRandomKiller.isKiller.Value = false
newRandomKiller.PlayerGui.MainGui.KillerText.Visible = false
newClassicSword:Destroy()
for i, v in pairs(Players:GetPlayers()) do
v.isKiller.Value = false
if v.isKiller.Value == false then
v.PlayerGui.MainGui.SurvivorText.Visible = false
end
end
end
end)
while Game_Is_ON == true and isGameAvailable == true do
-- INTERMISSION BREAK
hasGameStarted.Value = false
intermissionBreak()
teleportPlayersToLobby()
-- GAME IN PROGRESS
if #Players:GetChildren() >= 1 then
hasGameStarted.Value = true
roundInProgress()
teleportPlayersToGame()
elseif #Players:GetChildren() < 3 and #Players:GetChildren() >= 1 then
notEnoughPlayers()
elseif #Players:GetChildren() == 3 then
displayGameState.Text = "1 more player is needed to start the game"
end
end

1 comment
This is brilliant, i'm sure there's various of ways of accomplishing this, for instance, like with values and such, but i think this does the job! This will work with various of things such as checking if all the survivors are dead or not, so thank you in advance!