Help with easy music error please!

Delete the last Dependency:
“[ext_resource path=“res://Scenes/Game.tscn” type=“PackedScene” id=12]”
from the file, as well as:
“[node name=“PopSound” parent=“Player” instance=ExtResource( 12 )]”
and then try to load it again

1 Like

i deleted it,i am saving it and without anything just reload godot yes?

yes try that

1 Like

Thank you veryyy much you just saved my game.And now i will try to fix music problem

1 Like

No problem. If you have questions about your music problem, just ask them

1 Like

as you said i put music_player on the game.gd srcipt but not worked

extends Node2D


const SPAWN_INTERVAL = 0.4 # Adjust spawn interval as needed
var spawn_timer = 0.0
onready var music_player = $"/root/Menu/MusicPlayer"

func _process(delta):
	spawn_timer += delta
	if spawn_timer >= SPAWN_INTERVAL:
		spawn_bullet()
		spawn_timer = 0.0

func spawn_bullet():
	var bullet_scene = preload("res://Scenes/Bullet.tscn")
	var bullet_instance = bullet_scene.instance()
	var viewport_width = get_viewport().size.x
	bullet_instance.position.x = rand_range(0, viewport_width)
	get_tree().root.add_child(bullet_instance)

func playerDied(pop_effect_instance) -> void:
	add_child(pop_effect_instance)
	yield(get_tree().create_timer(3), "timeout")
	get_tree().change_scene("res://Scenes/Menu.tscn")
	music_player.stop()


I need some clarification. How many music_players do you have? Is there a music_player in your Game-Scene? Whats supposed to happen to the music when the player dies?

no there is not music_player in my player script, and i want when my player dies after it the music stops and reload on the menu scene(i just made it with autoplay but it was playing over the old music and it was bad)

Does the Game-Scene have a music_player?



no

Okay lets try this first:
Put this in your Menu.gd-script:

onready var music_player = get_node("MusicPlayer") 

func _ready():
    music_player.stop()
    music_player.play()
1 Like

made it

And does it change anything?


Maybe there is the problem?
onready var music_player = $“/root/Menu/MusicPlayer”

Delete this line from Game.gd

onready var music_player = $“/root/Menu/MusicPlayer” this one?

Delete Line 25 of Game.gd:

music_player.stop()
1 Like

Delete this one as well