Error opening file from user in a exported project

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

Hi, I’ve been having problems importing images from the user folder (so that players can have custom avatars). In the project the following script works perfect and does not generate any errors.

func _ready():
var img = Image.new()

var i = 6

while i != null:
	
	img.load("user://debug/avatars/"+str(i-5)+".png")

	if img.load("user://debug/avatars/"+str(i-5)+".png") != OK :
		i = null
		print ("res://Images/Avatars/Players/"+str(i)+".png error")
	else:
		img.save_png("res://Images/Avatars/Players/"+str(i)+".png")
		print ("res://Images/Avatars/Players/"+str(i)+".png imported")
		i = i+1
	

But when I compile the game it stops working and shows me the following error:

ERROR: load_image: Error opening file : user://debug/avatars/6.png
At: core/io/image_loader.cpp:56

Was it solved?

avnih | 2021-07-21 20:53