My script doesn't work properly

Hello I am working on a different type of management game. In my first script(Hero Script) I control movement and conditions and variables of hero. And in my Quest Screen Script I check the distance of hero to questGiver and If it is less then 1 it shows quest canvas. However, quest canvas shows up only if the last member’s distance is lesser than 1. Other parts of my scripts works pretty well but I can’t understand why this thing happens.
Thanks for your help.

Here are my scripts they are a bit long but they are parted to regions
Hero Script
Quest Screen Script

Trouble in your QuestScreen script. Look at Update(). In your “For” even if all heroes hit “SetActive(true)”, last one can hit “SetActive(false)”, so canvases not active.

You can use flags for visibility of canvases. Set flags to false before checks, set to true during checks if needed, dont set to false during checks. Then just use SetActive according to flags. Try this:

void Update()
{
    bool qCanvasVisible = false;
    bool rCanvasVisible = false;

    for (int i = 0; i < heroes.Length; i++)
    {
        if (heroes_.GetComponent<hero>().distance <= 1 && heroes*.GetComponent<hero>().haveItems == false)*_

qCanvasVisible = true;

if (heroes_.GetComponent().distance <= 1 && heroes*.GetComponent().haveItems == true)
rCanvasVisible = true;
}*_

qCanvas.SetActive(qCanvasVisible);
rCanvas.SetActive(rCanvasVisible);
}