I've got no clue what's going on! My game's not working!

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

I’m really sorry if this is nooby, but I’m new to godot.

I’ve got a game, and these lines of code glitch out the game and prevent it from running:

for _i in range(4 + level):
var c = Coin.instance()
$CoinContainer.add_child(c)
c.screensize = screensize # this line raises errors
c.position = Vector2(rand_range(0, screensize.x), rand_range(0, screensize.y))

it just says

Invalid set index ‘screensize’ (on base: ‘null instance’) with value of type ‘Vector2’.

anyone know why this happens / how to fix it?

:bust_in_silhouette: Reply From: exuin

This means that “c” is a “null instance”. I don’t know what c is so I can’t help you there.

Oh, sorry. It was an instance of another thing. I’ll add the full code for the main loop that’s causing the glitch…

endernerd12 | 2022-01-17 07:45

What is Coin?

exuin | 2022-01-17 10:58

An area2d with children animated sprite and collision shape.
this was my first project ever and I was copying from a book. I think I’ve got the right code. i checked 3 times. but I still get this error.

endernerd12 | 2022-01-18 01:31