Why doesn't my script recognize an autoload (C# Godot 4.0.3)?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By IncomprehensibleCode

My script does not recognize the autoload GlobalVar and keeps producing this error:

The name 'GlobalVar' does not exist in the current context [My First Project]

Here is the scripts that I used:
global_var.cs (for the global variables)

    using System;

namespace MyFirstProject
{
    public static class GlobalVar
    {
        public static float PlayerPositionX {get; set;}
        public static float PlayerPositionY {get; set;}
    }
}

player.cs (sets the variable)

using Godot;
using System;

public partial class Player : CharacterBody2D
{
    [Export]
    public int Speed { get; set; } = 400;

    public void GetInput()
    {
        Vector2 inputDirection = Input.GetVector("MoveLeft", "MoveRight", "MoveUp", "MoveDown");
        Velocity = inputDirection * Speed;
    }

	public void ResetPosVar()
	{
		GlobalVar.PlayerPositionX = Position.X;
		GlobalVar.PlayerPositionY = Position.Y;
	}

    public override void _PhysicsProcess(double delta)
    {
        GetInput();
        MoveAndSlide();
        ResetPosVar();
    }
}

tool.cs (using the variables)

using Godot;
using System;

public partial class Tool : CharacterBody2D
{
	public void GoToPlayer()
	{
		var newPosition = Position;
		newPosition.X = GlobalVar.PlayerPositionX;
		newPosition.Y = GlobalVar.PlayerPositionY;
		Position = newPosition;
	}
	public override void _Process(double delta)
	{
		GoToPlayer();
	}
}

Nevermind I fixed it, the global_var script just needed a change

using Godot;
using System;

public partial class GlobalVar : Node
{
    public static float PlayerPositionX {get; set;}
    public static float PlayerPositionY {get; set;}
}

IncomprehensibleCode | 2023-06-22 08:43