I'm making an application that randomly generates a set of characters for a game and then displays them in UI. I have an image for each character saved in res://, and the needed image (determined after randomization) is found in the file system and set as the texture for a TextureRect via code. This is an example of what I'm doing:
func add_texture(imagePath : String, objectPath : String):
var image = Image.new()
var texture = ImageTexture.new()
get_node(objectPath).texture = texture
This produces the error in the title. Is there a way to either fix the code or try something else that doesn't produce the error? I've been trying to troubleshoot this for about two hours and haven't found anything that fixes my problem.