i need to get a func from another script in the same scene

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

the code for the func i need is

extends Node3D
@onready var anim_player = $AnimationPlayer
@onready var sound = $AnimationPlayer/shot

func _ready():
pass

func Shoot():
if anim_player.is_playing():
pass
else:
anim_player.play(“Rig|AK_Shot”)
sound.pitch_scale(randf_range(.7, .9))

when i press the fire key it crashes

class_name Player
extends CharacterBody3D

@onready var Gun = $Head/Camera/AK74

func _ready():
pass

func _physics_process(delta : float) → void:
if Input.is_action_just_pressed(“fire”):
Gun.Shoot

“when i press the fire key it crashes” - what’s the error message?
is your CharacterBody3D a child of your Node3D or vice versa?
It’s common to use signals when communicating between nodes.
use the code formatting when you post code here, it’s a pain to read otherwise. highlight your code and press ctrl+k

k4gi | 2023-02-23 00:38

it said, “node not found animationplayer relative to root/ak74 node not found animationplayer/shot relative to root/ak74” and “node not found head/camera/ak74 relative to root/main/player” Attempt to call function ‘shoot’ in base ‘null instance’ on a null instance. and the node is a child of my player

zippyman146123 | 2023-02-23 01:20

NVM fixed it

zippyman146123 | 2023-02-23 01:39

How did you fix it?

Ertain | 2023-02-23 05:00

i forgor but it had to do with the gun Attempt to call function ‘shoot’ in base ‘null instance’ on a null instance paste that in google and you will find it in one of the links

zippyman146123 | 2023-02-23 05:31