- Edited
I have a project that will eventually have hundreds of clothing objects, and I'm trying to allow my game to populate a menu with buttons representing random clothing objects, that when pressed, will instance and parent that object to a character.<br /><br />When I run the code below, I get the error message:<br />"Expected string constant as 'preload' argument."<br /><br />var subfolder = str(##code for choosing a subfolder##)<br />var scn = str(##code for choosing a scene file within that folder##)<br /><br />var model = str("res://assets/character/clothing/" + (subfolder) + (scn))<br />var newobject = preload(model).instance()<br />get_node("armature").add_child( newobject )<br /><br />When I 'print(model)', I get the intended result. Is there a way to trick the engine into accepting my 'model' variable as a constant? Or is there another/better way to accomplish what I am trying to do?<br /><br />Thanks