The problematic function is shown below.
The problem strangely only happens after exporting, and when running from the editor everything is done perfectly and I can use the paths to randomly instance things.
I keep getting "Couldn't start file stream!" message which means it can't find the directory maybe? (Based on this from the docs)
The value for path is "res://episodes/3_end/". I also tried "/episodes/3_end/" but then it breaks everywhere.
var paths = 
var dir = Directory.new()
dmsg("\nCouldn't start file stream!\n")
var file = dir.get_next()
if file == "":
elif (not file.begins_with(".") and file.extension() == "tscn"):
paths.append(file.basename()+"." + file.extension())
Thank you all.