How do I fix "The assigned value doesn't have a set type; the variable type can't be inferred"

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

So I have been following a tutorial made by GDQuest called Make your first 2D game with Godot. I have made it far into the tutorial, but when it came to interrupting the jump, I put in the same code the GDQuest person put in, but I ended up getting the error “The assigned value doesn’t have a set type: the variable type can’t be inferred”. I have re-watched that section of the tutorial multiple times, making sure I haven’t missed anything I should have put in prior to the code, but I couldn’t find anything, I even re-entered the code making sure I didn’t make any typos, but there was no typo and the error still pops up. This is the code that’s giving me some major trouble:

var is_jump_interrupted: = Input.is_action_just_released("jump") and velocity.y < 0.0
:bust_in_silhouette: Reply From: timothybrentwood
var is_jump_interrupted = Input.is_action_just_released("jump") and velocity.y < 0.0

Remove the colon. The colon tells Godot what kind of variable to expect, in this case it’s not really useful.

var my_vector : Vector2

will make it so it gives you a warning if you do something like this later:

my_vector = 12

That worked. Thank you so much!

AshTheKindra | 2021-05-22 17:35