If you are redirected to this tutorial by a member of one of the Skript communities, that will probably mean that your indentation was wrong. You probably did not know what they meant and you just wanted your error to be resolved, but this is actually a rather small, but really important aspect of coding in general, so that's why this tutorial was created.
So basically, if you experienced the error "Error: Indentation error at line X, expected X tabs/spaces, but found X tabs/spaces" or something similar, and you don't know how to fix it, read this tutorial.
Indentation is placing text in code further to the right, to allow the parser to know this is a different section of the code. Most programming language don't care about indentation, their parser can handle it correctly without, but Skript can't, because of its rich, English-like syntax.
That's why indentation is really important and you should always take care of it. See an example below.
on script load: # Here I indentated with one tab, to clarify this is the section after the event. if "Hello" does not equal "Bye": # Here I indentated with two tabs, because this is a section after a condition, that already was indentated. send "How are you?" to console
When should I indentate?
on script load: #This is an event, so the next line should be indentated once.
if attacker is a player: # Condition, so the next line should be indentated once. else if type of current inventory of player is anvil inventory: # Also a condition. else: # Believe it or not, this is a condition as well.
while player is online: # Something that requires a colon is a section and therefore needs indentation. loop all players:
function myFunc(): # A function is declared at root-level. command /test: # Same for commands.
How should I indent?
Look at the examples below and see if you understand why indentation is needed.
on damage: # One indentation because of the event. if attacker is a player: # Two indentations because of the event and the condition. if victim is a player: # Three indentations because of the event and the two conditions. broadcast "%attacker% murdered %victim%" # One indentation because of the event else if attacker is a zombie: # Two indentations because of the event and the condition. loop all players: # Three indentations because of the event, the condition and the section (looping). give a diamond sword to loop-player # Again root-level, because we are in a new event, so no indentation. on rightclick with pickaxe: # One indentation because of the event. add 1 to player's balance