Invalid get index 'zoom'(on base: 'null instance')

Godot Version



I am beginner so sorry for this probably stupid question; I’ve written a code to allow player to zoom in/out their camera and it worked in previous backup of my game and now it isn’t. I did not changed anything related to this script, i’ve done some research but nothing seem to be helpful for me, could someone help?

this happen because the camera_2d is not yet ready, so it’s null
try add

await get_tree().physics_frame

at the first line of zoom() function

if this doesnt work, then you can just


if not camera_2d:

at the first line of zoom() function

1 Like

second solution worked, thank you

1 Like