one mistake that I do not know how to solve

Godot Version

Godot v.4.6.1

Question

Expected indented block after “if” block.

Indentation matters in GDScript.
The lines after the if statement should be indented more than the if statement itself.

Check this article for examples of proper indentation:

2 Likes

Yeah what the guy directly over me said is correct but here is basically how it works. If you have an if statement without an indent behind it it will work like this :

Example if statement: if grass ==green do …

Without correct indentation the computer will do this, check if the grass is green, then no matter what continue with the next line, aka does nothing except for wasting processing power.

The same code with correct indentation will do this, check if the grass is green then if it is run the next code.

Godot has an inbuilt error that tells you if nothing would happen and stops you from making useless if statements.

Hope that helped.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.