Game breaking, lua error in game, need help fixing

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    A cool, unusual game of betrayal and pvp.
  2. What is the issue? Include screenshots / videos if possible!
    it… breaks.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    none.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

my code:

local plrs = 0
local delay3 = false
local delay4 = false
local delay = false
local delay5 = false
local timer = 60
local Skip = false
local Headband = Instance.new("Hint")
local Clues = {"The monster must be near someone to kill them.", "The monster can only kill before voting.", "The monster looks like one of you.", "The monster cannot vote."}
game["Run Service"].Heartbeat:Connect(function()
	if workspace.MonsterTurn.Value == true then
		if delay5 == false then
			delay5 = true
			wait(1)
			timer -= 1
			print(timer)
			if timer < 0 then
				Headband.Text = "The monster killed nobody within 1 minute. Skipping."
				wait(5)
				workspace.SkipTurn.Value = true
			end
			delay5 = false
		end
	else
		timer = 60
	end
	if delay == false then
		delay = true
		Headband.Parent = workspace
		workspace.GameOver.Value = false
		for i = 1, 30 do
			Headband.Text = "Round starting in " .. 30 - i .. " seconds."
			wait(1)
		end
		if #game.Players:GetPlayers() < 4 then
			Headband.Text = "Not Enough Players."
			wait(3)
		else
			Headband.Text = "You have time to split up. Do so."
			for i, plr in pairs(game.Players:GetPlayers()) do
				if plr.Character then
					plr.Character:PivotTo(workspace.Spawns:GetChildren()[math.random(1, #workspace.Spawns:GetChildren())].CFrame)
					plr:AddTag("Ingame")
				end
			end
			
			workspace.Fraud.Value = game.Players:GetPlayers()[math.random(1, #game.Players:GetPlayers())]
			while workspace.GameOver.Value == false do
				wait()
				if delay4 == false then
					delay4 = true
					Headband.Text = "The monster is attacking."
					workspace.MonsterTurn.Value = true
					workspace.LastVoted.Value = game
					while workspace.GameOver.Value ~= true and Skip ~= true do
						wait()
						if workspace.SkipTurn.Value == true then
							Skip = true
							print("Skip!")
						end
					end
					Skip = false
					workspace.SkipTurn.Value = false
					Headband.Text = "Figure out and kill the monster. It is everybody (not the monster)'s turn. clue: " .. Clues[math.random(1, #Clues)]
					workspace.MonsterTurn.Value = false
					workspace.LastVoted.Value = game
					while workspace.GameOver.Value ~= true and Skip ~= true do
						wait()
						if workspace.SkipTurn.Value == true then
							Skip = true
							print("Skip!")
						end
					end
					Skip = false
					workspace.SkipTurn.Value = false
					if workspace.GameOver.Value == true then
						if workspace.Lost.Value == true then
							Headband.Text = "The monster won. The monster was: " .. workspace.Fraud.Value.DisplayName
							workspace.Lose:Play()
						else
							Headband.Text = "The survivors win. The monster was: " .. workspace.Fraud.Value.DisplayName
							workspace.Win:Play()
						end
						for i, plr in pairs(game.Players:GetPlayers()) do
							plr:LoadCharacter()
						end
						wait(5)
						delay = false
						delay4 = false
					end
				end
			end
			end
	end
end)

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Char)
		local Prompt = Instance.new("ProximityPrompt")
		local Attach = Instance.new("Attachment")
		Attach.Parent = Char.Head
		Attach.Position = Vector3.new(0, 3, 0)
		Prompt.Parent = Attach
		Prompt.RequiresLineOfSight = false
		Prompt.HoldDuration = 1
		Prompt.MaxActivationDistance = 7
		Prompt.ActionText = "Vote/Kill"
		Prompt.ObjectText = Player.DisplayName
		Prompt.Triggered:Connect(function(Plr)
			if ((Plr ~= Player and workspace.Fraud.Value ~= Plr and workspace.MonsterTurn.Value == false) or (workspace.Fraud.Value == Plr and workspace.MonsterTurn.Value == true)) and Player:HasTag("Ingame") and Plr:HasTag("Ingame") then
				Char:BreakJoints()
				if Player:HasTag("Ingame") then
					Player:RemoveTag("Ingame")
					workspace.LastVoted.Value = Player
					workspace.SkipTurn.Value = true
					for i, bp in pairs(Char:GetChildren()) do
						if bp:IsA("BasePart") then
							bp.Color = Color3.fromRGB(255, 0, 4)
						end
					end
					workspace["Scare Stings 11"]:Play()
				end
			end
		end)
	end)
end)
local Delay2 = false
workspace.LastVoted.Changed:Connect(function(E)
	workspace.LastVoted.Value = nil
	if Delay2 == false then
		Delay2 = true
		plrs = 0
		workspace.Lost.Value = true
		for i, plr in pairs(game.Players:GetPlayers()) do
			if plr:HasTag("Ingame") then
				plrs += 1
			end
			if plr == workspace.Fraud.Value and not plr:HasTag("Ingame") then
				workspace.Lost.Value = false
				workspace.GameOver.Value = true
			end
		end
		if plrs < 3 then
			workspace.GameOver.Value = true
		end
		Delay2 = false
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Could you be any more vague about the problem?

vague… i can describe it better, not vague-er though.
It happens when the second part occurs, when the survivors get to kill who they think is the monster, and for some reason, it never transitions to the monster’s turn.