Hello there, I’m Pixeluted I trying do if Murderer or Informant isn’t here then stop game but every round is start and then stop and doing it again and again I debugging it here is output
Script here
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local TimeLeft = ReplicatedStorage.Values.TimeLeft
local PlayersLefts = ReplicatedStorage.Values.PlayersLefts
local MonsterHealth = ReplicatedStorage.Values.MonsterHealth
local PlayersToStart = 1
local function toHMS(s)
return ("%02i:%02i"):format( s/60%60, s%60)
end
local function TeleportPlayers(AvaiblePlayers)
for _,player in pairs(AvaiblePlayers) do
local Spawn = workspace.Map.Spawns:GetChildren()
if player and player.Character and player.Character.HumanoidRootPart then player.Character.HumanoidRootPart.CFrame = Spawn[math.random(1,#Spawn)].CFrame + Vector3.new(0,5,0) end
end
end
while wait(0.0001) do
repeat
print("Not Enough player")
wait(1)
until #game.Players:GetChildren() >= PlayersToStart
-- Choosing roles
local Players = game.Players:GetChildren()
local Informant = Players[math.random(1,#Players)]
print("Informat is"..Informant.Name)
local Monster = Players[math.random(1,#Players)]
if Monster.Name ~= Informant.Name then elseif Monster.Name == Informant.Name then Monster = Players[math.random(1,#Players)] end
print("Murderer is "..Monster.Name)
-- Informating player about role
TeleportPlayers(game.Players:GetChildren())
wait(2)
for _,player in pairs(Players) do
player.PlayerGui.HUD.Role.Visible = true
if player.Name == Informant.Name then
player.PlayerGui.HUD.Role.Role.Text = "Informant"
elseif player.Name == Monster.Name then
player.PlayerGui.HUD.Role.Role.Text = "Murderer"
elseif player.Name ~= Informant.Name and player.Name ~= Monster.Name then
player.PlayerGui.HUD.Role.Role.Text = "Hunter"
end
end
wait(2)
for _,player in pairs(Players) do
player.PlayerGui.HUD.Role.Visible = false
if player.Name == Monster.Name then
local GameTag = Instance.new("IntValue",player.Character)
GameTag.Name = "Murderer"
print("Tag for Murderer Created")
if player.Name == Informant.Name then
local GameTag = Instance.new("IntValue",player.Character)
GameTag.Name = "Informant"
print("Tag for Informant created")
end
if player.Name ~= Informant.Name and player.Name ~= Monster.Name then
local GameTag = Instance.new("IntValue",player.Character)
GameTag.Name = "GameTag"
end
end
end
-- Timer starts
local Table = {}
for _,player in pairs(Players) do
table.insert(Table,player.Name)
end
wait(3)
for i = 120,0,-1 do
local Time = toHMS(i)
TimeLeft.Value = Time
local Murderingame = true
local Infromantingame = true
for _,player in pairs(Players) do
if not player.Character:FindFirstChild("GameTag") and player.Name ~= Monster.Name and player.Name ~= Informant.Name then
local PlayerInTable = table.find(Table,player.Name)
table.remove(Table,PlayerInTable)
elseif not player.Character:FindFirstChild("Murderer") and player.Name == Monster.Name then
local PlayerInTable2 = table.find(Table,player.Name)
table.remove(Table,PlayerInTable2)
Murderingame = false
print("Murderer isn't here")
elseif not player.Character:FindFirstChild("Informant") and player.Name == Informant.Name then
local PlayerInTable3 = table.find(Table,player.Name)
table.remove(Table,PlayerInTable3)
print("Informant isn't here")
Infromantingame = false
end
end
if Murderingame == false then
break
elseif Infromantingame == false then
break
end
end
end
Thank for read