I get this "Cannot call method ‘play’ on a null value.” when I touch a object this is the script
ass_name Item extends Area2D @exportexport var reproductor: AudioStreamPla@exporter2D @export var texture: CompressedTexture2D:
set(value):
texture = value
$Sprite2D.texture = value
enum ItemType{Iphone,Balon,Luces,Pizza,Mando} @export var type:ItemType
Please use preformatted text with three backticks ``` for code snippets, otherwise it’s very hard to read.
This error means the object on which you’re calling the play() method is null at the time of calling. In your code, I can see only this part where play() method is mentioned:
That means, reproductor is most likely not assigned in the Inspector. Can you check if you assigned something to the reproductor variable?
Well then if it’s printed as null, then you might want to recheck your assignment, because it means it’s not assigned.
You can also go into the Remote scene tree after starting the game and see how your objects are assigned
reproductor is a member variable of your object instance.
You play the sound but immediately queue your object up for deletion.
My guess is that your object gets deleted (and takes reproductor down with it) before you hear a sound.
Comment out queue_free() and see if your sound plays.