Hi there, I am currently trying to script a round system for a new game. What this round system is supposed to do, is start the match when there is 2 or more players and then choose 1 of the 3 maps. After that, it’s supposed to check how many votes there is towards both a AI killer and a player controlled killer and then choose the one with more votes. Finally, it’s supposed to teleport all the players to the map where the round is played out until either the timer runs out and the survivors wins or the killer slays all of the players and the killer wins.
The problem, is that when a player plays as the killer it won’t start the match countdown and when the player playing as the killer kills all of the players, The system breaks.
I have already tried re-scripting it numerous times, I’ve added things in and taken them out. I’ve searched the web for help and i can’t find a solution. Does anyone know how to help? If so please do.
--Coeman_577
local StatusGui = game. ReplicatedStorage:WaitForChild("Time")
while wait(1) do
if game.Workspace.Spectators.Value >= 2 and game.Workspace.Survivors.Value == 0 and game.Workspace:FindFirstChild("JeffAI") == nil then
print("2+ players")
game.ReplicatedStorage.Timer.Value = 30
for Intermission = 30,1,-1 do
if game.Workspace.Spectators.Value >= 2 then
game.Lighting.ClockTime = 14
game.ReplicatedStorage.Timer.Value = game.ReplicatedStorage.Timer.Value - 1
StatusGui.Value = "Night begins in: "..game.ReplicatedStorage.Timer.Value
wait(1)
if Intermission == 1 then
StatusGui.Value = "Choosing map"
wait(3)
--Chooses map
local Map = math.random(1,3)
if Map == 1 then
local M1 = Instance.new("Message", game.Workspace)
M1.Text = "Map chosen: White Place"
wait(5)
M1:Remove()
game.ReplicatedStorage["White Place"]:Clone().Parent = game.Workspace
game.ReplicatedStorage.TeamKiller1.Parent = game.Workspace
elseif Map == 2 then
local M2 = Instance.new("Message", game.Workspace)
M2.Text = "Map chosen: Hell's Carnival"
wait(5)
M2:Remove()
game.ReplicatedStorage["Hell's Carnival"]:Clone().Parent = game.Workspace
game.ReplicatedStorage.TeamKiller2.Parent = game.Workspace
elseif Map == 3 then
local M3 = Instance.new("Message", game.Workspace)
M3.Text = "Map chosen: Cult Mansion"
wait(5)
M3:Remove()
game.ReplicatedStorage["Cult Mansion"]:Clone().Parent = game.Workspace
game.ReplicatedStorage.TeamKiller3.Parent = game.Workspace
end
--Chooses mode and killer
StatusGui.Value = "Tallying votes"
wait(3)
game.Workspace.TeamSpectators.Parent = game.ReplicatedStorage
if game.Workspace.AI.Value > game.Workspace.Player.Value then
local Insane = game.ReplicatedStorage["JeffAI"]:Clone()
Insane.Parent = game.Workspace
if Map == 1 then
Insane:MoveTo(Vector3.new(34.44, 24.166, -99.83))
wait(1)
game.ReplicatedStorage.TPBrick1.Parent = game.Workspace
game.Workspace.TeamKiller1.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick1.Parent = game.ReplicatedStorage
elseif Map == 2 then
Insane:MoveTo(Vector3.new(180.7, 1.5, 270.8))
wait(1)
game.ReplicatedStorage.TPBrick2.Parent = game.Workspace
game.Workspace.TeamKiller2.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick2.Parent = game.ReplicatedStorage
elseif Map == 3 then
Insane:MoveTo(Vector3.new(-154.497, 6.77, 109.31))
wait(1)
game.ReplicatedStorage.TPBrick3.Parent = game.Workspace
game.Workspace.TeamKiller3.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick3.Parent = game.ReplicatedStorage
end
local V1 = Instance.new("Message", game.Workspace)
V1.Text = "Playing against: Artificial Intelligence Killer"
wait(5)
V1:Remove()
wait(1)
elseif game.Workspace.Player.Value > game.Workspace.AI.Value then
local V2 = Instance.new("Message", game.Workspace)
V2.Text = "Playing against: Player Controlled Killer"
wait(5)
V2:Remove()
dft = {}
function GetPlayers()
local c = game.Players:GetChildren()
for i = 1, #c do
table.insert(dft, c[i].Name)
end
end
function Randomize()
GetPlayers()
local d = math.random(1, #dft)
local s = d
local h = Instance.new("Message", game.Workspace)
h.Text = "The killer is... "..dft[s].."!"
wait(5)
h:Remove()
local rndm = game.Players:FindFirstChild(dft[s])
game.ReplicatedStorage.Knife:Clone().Parent = rndm.Backpack
if (rndm ~= nil and Map == 1) then
local Player = rndm.Character
Player:MoveTo(Vector3.new(34.44, 24.166, -99.83))
wait(1)
game.ReplicatedStorage.TPBrick1.Parent = game.Workspace
game.Workspace.TeamKiller1.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick1.Parent = game.ReplicatedStorage
elseif (rndm ~= nil and Map == 2) then
local Player = rndm.Character
Player:MoveTo(Vector3.new(180.7, 1.5, 270.8))
wait(1)
game.ReplicatedStorage.TPBrick2.Parent = game.Workspace
game.Workspace.TeamKiller2.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick2.Parent = game.ReplicatedStorage
elseif (rndm ~= nil and Map == 3) then
local Player = rndm.Character
Player:MoveTo(Vector3.new(-154.497, 6.77, 109.31))
wait(1)
game.ReplicatedStorage.TPBrick3.Parent = game.Workspace
game.Workspace.TeamKiller3.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick3.Parent = game.ReplicatedStorage
end
end
wait(1)
Randomize()
wait(1)
elseif game.Workspace.Player.Value == game.Workspace.AI.Value then
local Vote = math.random(1,2)
if Vote == 1 then
local V3 = Instance.new("Message", game.Workspace)
V3.Text = "Playing against: Player Controlled Killer"
wait(5)
V3:Remove()
dft = {}
function GetPlayers()
local c = game.Players:GetChildren()
for i = 1, #c do
table.insert(dft, c[i].Name)
end
end
function Randomize()
GetPlayers()
local d = math.random(1, #dft)
local s = d
local h = Instance.new("Message", game.Workspace)
h.Text = "The killer is... "..dft[s].."!"
wait(5)
h:Remove()
local rndm = game.Players:FindFirstChild(dft[s])
game.ReplicatedStorage.Knife:Clone().Parent = rndm.Backpack
if (rndm ~= nil and Map == 1) then
local Player = rndm.Character
Player:MoveTo(Vector3.new(34.44, 24.166, -99.83))
wait(1)
game.ReplicatedStorage.TPBrick1.Parent = game.Workspace
game.Workspace.TeamKiller1.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick1.Parent = game.ReplicatedStorage
elseif (rndm ~= nil and Map == 2) then
local Player = rndm.Character
Player:MoveTo(Vector3.new(180.7, 1.5, 270.8))
wait(1)
game.ReplicatedStorage.TPBrick2.Parent = game.Workspace
game.Workspace.TeamKiller2.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick2.Parent = game.ReplicatedStorage
elseif (rndm ~= nil and Map == 3) then
local Player = rndm.Character
Player:MoveTo(Vector3.new(-154.497, 6.77, 109.31))
wait(1)
game.ReplicatedStorage.TPBrick3.Parent = game.Workspace
game.Workspace.TeamKiller3.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick3.Parent = game.ReplicatedStorage
end
end
wait(1)
Randomize()
wait(1)
elseif Vote == 2 then
local Insane2 = game.ReplicatedStorage["JeffAI"]:Clone()
Insane2.Parent = game.Workspace
if Map == 1 then
Insane2:MoveTo(Vector3.new(34.44, 24.166, -99.83))
wait(1)
game.ReplicatedStorage.TPBrick1.Parent = game.Workspace
game.Workspace.TeamKiller1.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick1.Parent = game.ReplicatedStorage
elseif Map == 2 then
Insane2:MoveTo(Vector3.new(180.7, 1.5, 270.8))
wait(1)
game.ReplicatedStorage.TPBrick2.Parent = game.Workspace
game.Workspace.TeamKiller2.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick2.Parent = game.ReplicatedStorage
elseif Map == 3 then
Insane2:MoveTo(Vector3.new(-154.497, 6.77, 109.31))
wait(1)
game.ReplicatedStorage.TPBrick3.Parent = game.Workspace
game.Workspace.TeamKiller3.Parent = game.ReplicatedStorage
wait(1)
game.Workspace.TPBrick3.Parent = game.ReplicatedStorage
end
local V1 = Instance.new("Message", game.Workspace)
V1.Text = "Playing against: Artificial Intelligence Killer"
wait(5)
V1:Remove()
wait(1)
game.ReplicatedStorage.TeamSpectators.Parent = game.Workspace
game.ReplicatedStorage.RoundTimer.Value = 210
--Round Begins
for Round = 210,1,-1 do
if game.Workspace.Survivors.Value >= 1 and game.Workspace.Killer.Value == 1 and game.Workspace:FindFirstChild("JeffAI") == nil then
game.ReplicatedStorage.RoundTimer.Value = game.ReplicatedStorage.RoundTimer.Value - 1
StatusGui.Value = "Night ends in: "..game.ReplicatedStorage.RoundTimer.Value
wait(1)
elseif game.Workspace.Survivors.Value >= 1 and game.Workspace.Killer.Value == 0 and game.Workspace:FindFirstChild("JeffAI") ~= nil then
game.ReplicatedStorage.RoundTimer.Value = game.ReplicatedStorage.RoundTimer.Value - 1
StatusGui.Value = "Night ends in: "..game.ReplicatedStorage.RoundTimer.Value
wait(1)
if game.Workspace.Survivors.Value == 0 then
StatusGui.Value = "The killer wins!"
if game.Workspace:FindFirstChild("JeffAI") ~= nil then
game.Workspace:FindFirstChild("JeffAI"):Destroy()
end
game.ReplicatedStorage.TPBrick.Parent = game.Workspace
wait(1)
game.Workspace.TPBrick.Parent = game.ReplicatedStorage
if Map == 1 then
game.Workspace["White Place"]:Destroy()
elseif Map == 2 then
game.Workspace["Hell's Carnival"]:Destroy()
elseif Map == 3 then
game.Workspace["Cult Mansion"]:Destroy()
end
wait(1)
elseif game.Workspace.Killer.Value == 0 and game.Workspace:FindFirstChild("JeffAI") == nil or Round == 1 or Round == 1 and game.Workspace:FindFirstChild("JeffAI") ~= nil then
StatusGui.Value = "Survivors win!"
if game.Workspace:FindFirstChild("JeffAI") ~= nil then
game.Workspace:FindFirstChild("JeffAI"):Destroy()
end
game.ReplicatedStorage.TPBrick.Parent = game.Workspace
wait(1)
game.Workspace.TPBrick.Parent = game.ReplicatedStorage
if Map == 1 then
game.Workspace["White Place"]:Destroy()
elseif Map == 2 then
game.Workspace["Hell's Carnival"]:Destroy()
elseif Map == 3 then
game.Workspace["Cult Mansion"]:Destroy()
end
wait(1)
end
end
end
end
end
end
end
end
else
StatusGui.Value = "Waiting for 1 more player"
end
end