Script Path is pointing to Scene instead

Godot Version

4.4.1

Question

I am creating a kind of chess app similar to something made by sebastian lague. But when i opened godot today and started working on my code, I kept throwing the same error.

I have a Square.tscn scene which has a Node2D called Square, with a ColorRect called background and Sprite2D called PieceSprite as children. Everything was working fine until today.

I tried to make a function to be able to change the texture of the sprite2d in a c# script called Square.cs.

public void SetPieceSprite(Texture2D pieceTexture) { _pieceSprite.Texture = pieceTexture; }

(sorry if it does not look pretty, still new around here)

This kept throwing a Object reference not set to a reference error, and when I checked the script that is attached to the Node2D Square, it shows a path to Square.tscn, the scene, instead of the script.

I tried to change it, but after pressing create, it still is connected to the scene no matter how many times i try.

This is Square.tscn for reference

` [gd_scene load_steps=2 format=3 uid=“uid://3cw70bljyr6q”]

[ext_resource type=“Script” uid=“uid://dhq8xtklmc50c” path=“res://scripts/Square.cs” id=“1_rb13l”]

[node name=“Square” type=“Node2D”]
script = ExtResource(“1_rb13l”)

[node name=“Background” type=“ColorRect” parent=“.”]
offset_right = 80.0
offset_bottom = 80.0

[node name=“PieceSprite” type=“Sprite2D” parent=“.”]
scale = Vector2(0.187354, 0.187354)
centered = false `

please help

You’re going to need to give us more code, and a screenshot of your scene tree would be more informative than a description.

Please format your code by placing ``` on the lines above and below your code. I recommend including the whole script.