A more extensive tutorial on variables in Skript.


Variables are Skript's way of saving data. Every variable has a name and a value, or some sort of stored data. You can use variables in place of triggers. e.g. you can replace a location with a variable that holds a location. All variables are saved in the variables.csv file.

Using Variables

To make variables, they need to be in curly brackets {}.

on chat:
set {_m} to "%message%"

In the example above, the player's message is stored in the local variable {_m}. There are four types of variables. Normal, Local, List, and Options. Variable names also have to be unique. (There can't be two variables with the same name.)

Normal Variables

Normal variables are the standard variable you can use in Skript.

on chat:
set {message.%player%} to message

In the above example, the player's message is stored in a normal variable named "message". This variable can be used globally. (Across your scripts.)

Local Variables

Local variables are local to the current code section, and aren't saved.

# This is one code section, you can only use {_m} in this section
on chat:
set {_m} to message
# This is another code section. You can't use {_m} here, it doesn't exist.
on death:
set {_v} to victim

Take a look at the example above. The {_m} variable is the message in the chat event. You can only use {_m} in that code section. A code section is started when you have an event or trigger.

List Variables

List variables are a bit advanced for beginners, but easy to master. A list variable can hold multiple values, or, a list of values.

command /test:
set {_list::*} to "a", "b", and "c"
send "%{_list::*}%" to player

The command above would send "a, b, c" to the player. You can also get the size of a list variable by using the size expression.

command /hello:
add 1 to {hello-count::%player%}
send "%{hello-count::%player%}

Some list variables, only have one value. Reference the above example. List variables are more efficient to use because you can easily grab values for all players. Look at the hello-count variable.

command /hello-values:
send "%{hello-count::*}%"

The * symbol gets all the values for a list variable, as you see in the first code example in the List Variables section.


Options are basicly shortcuts in your code. Usually at the top of your Skript code file, you would declare options.

a: Hello World!

Options are used just like variables with curly brackets. But right before the option name, you need the @ symbol. Here's an example usage of the option a.

on chat:
send "{@a}" to player

With the code above, when a player chats, they would be sent "Hello World!"


You just learned how to use variables in Skript.