Nothing is working : (

So when I run the game and enter the answer, nothing happens, the input field just clears itself

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class GameManager : MonoBehaviour
{
    public static List<(string question, string answer)> availQuest;
    private string crntQ;
    private string crntA;

    void Start()
    {
        InitializeQuestions();
        Randomize();
    }
    
    public void InitializeQuestions()
    {
        availQuest = new List<(string, string)> {
            ("3 - 2", "1"), // Answer is 1
            ("2 x 4", "8"), // Answer is 8
            ("50 - 30", "20"), // Answer is 9.5
            ("0 x 0", "0"), // Answer is -16
            ("5 + 5 - 3", "7"), // Answer is 7
            ("10 x 5", "50"), // Answer is 72
            ("6(2) - 2", "10"), // Answer is 27
            ("5 + 5", "10"), // Answer is 10
            ("10 / 2", "5"), // Answer is 9
            ("2 + 2", "4") // Answer is 4
        };
    }
    public void Randomize()
    {
        if (availQuest.Count > 0)
        {
            int rnd = Random.Range(0, availQuest.Count);
            crntQ = availQuest[rnd].question; 
            crntA = availQuest[rnd].answer;
            availQuest.RemoveAt(rnd);
        }
    }
    public string CurrentQ()
    {
        return crntQ;
    }
    public string CurrentA()
    {
        return crntA;
    }
using System;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.Collections.Generic;

public class InputHandler : MonoBehaviour
{
    [SerializeField] InputField inputField;
    [SerializeField] Text textResult;
    private GameManager gm;
    private Queue<GameManager> enemyQ = new Queue <GameManager>();
    void Start()
    {
    }
    void Update()
    {
        if (inputField.isFocused && (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter)))
        {
            InputVal();
        }
    }
    public void AddQ(GameManager enemy)
    {
        enemyQ.Enqueue(enemy);
    }
    public void InputVal()
    {
        string input = inputField.text.Trim();
        if (enemyQ.Count > 0)
        {
            GameManager crntE = enemyQ.Peek();
            if (input.Equals(crntE.CurrentA().Trim(), StringComparison.InvariantCultureIgnoreCase))
            {
                textResult.text = "CORRECT!";
                textResult.color = Color.yellow;
                Debug.Log("Correct Answer: " +crntE.CurrentA());
                Destroy(crntE.gameObject); 
                enemyQ.Dequeue(); 
                if (enemyQ.Count > 0)
                {
                    enemyQ.Peek().Randomize(); 
                }
            }
            else
            {
                textResult.text = "INCORRECT!";
                textResult.color = Color.red;
                Debug.Log("Correct Answer: " +crntE.CurrentA());
            }
        }
        inputField.text = string.Empty;
        inputField.ActivateInputField();
    }

try using Debug.Log() to see if the field had any value when you go into InputVal()?
Or maybe pressing enter creates new line (if its multiline input?)

for input field, you could use events, to know when user is finished or changed text:
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/script-InputField.html

Even the debug won’t show me anything : (

Seems to work on my test scene,
can you record small gif/video from it to see what happens?
(or screenshots from your inputfield or related components)


Yeah, it was empty. How do I make it so that it will receive value?

It seems to print “3” as value there? (“input received: 3”)

It’s from the Inputfield, that’s the answer text I entered for the question that was displayed in Text Mesh pro

enemyQ.count is empty,
so that code inside InputVal(), if (enemyQ.Count > 0), wont get to run…

should there be enemies, is somebody calling AddQ()?

void Start()
    {
        InitializeQuestions();
        Randomize();
        InputHandler inputHandler = FindObjectOfType<InputHandler>();
    if (inputHandler != null)
    {
        inputHandler.AddQ(this); // Adds this GameManager to the queue
    }
    else
    {
        Debug.LogError("InputHandler not found in the scene.");
    }

I removed this code from GameManager because even if my answer to the question is correct, it says it’s not.