Skip to main content
Variables store data that you can use throughout your scripts. They can hold any type of value and can persist across server restarts.

Variable Types

Local Variables

Local variables start with {_ and only exist within their current trigger:
command /timer:
	trigger:
		set {_difference} to now - {timer}
		send "Time difference: %{_difference}%"
		# {_difference} is deleted after the command finishes
Use local variables for temporary calculations and data that doesn’t need to persist.

Global Variables

Global variables persist across server restarts and are accessible everywhere:
command /timer:
	permission: skript.example.timer
	trigger:
		if {timer} is set:
			send "This command was last run %time since {timer}% ago."
		else:
			send "This command has never been run."
		set {timer} to now
Global variables are stored in a database file. Too many variables can slow down your server.

Variable Naming

Variables are enclosed in curly braces {variable}:
{timer} # Simple variable
{balance::%uuid of player%} # Player-specific variable
{homes::%uuid of player%::home} # Nested variable
{_local} # Local variable (not saved)

Best Practices

Use UUIDs

Store player data using uuid of player instead of player names, which can change

Descriptive Names

Use clear, descriptive variable names like {homes::...} not {h::...}

Local First

Use local variables for temporary data to avoid cluttering the database

Organize Data

Use colons :: to organize related variables into logical groups

List Variables

List variables store multiple values using the ::* syntax:
# Add items to a list
add "bacon" to {_shopping list::*}
add "eggs" to {_shopping list::*}
add "oats" and "sugar" to {_shopping list::*}

# Set specific indices
set {_items::1} to "apple"
set {_items::2} to "banana"
set {_items::3} to "orange"

Looping Lists

Iterate through list variables:
command /shoppinglist:
	permission: skript.example.list
	trigger:
		add "bacon" to {_shopping list::*}
		add "eggs" to {_shopping list::*}
		add "oats" and "sugar" to {_shopping list::*}
		send "You have %size of {_shopping list::*}% things in your shopping list:"
		loop {_shopping list::*}:
			send "%loop-index%. %loop-value%"
		send "You bought some %{_shopping list::1}%!"
		remove "bacon" from {_shopping list::*}
		send "Removing bacon from your list."
		send "You now have %size of {_shopping list::*}% things in your shopping list."

Player-Specific Variables

Store data per player using their UUID:
on join:
	set {items::%uuid of player%::helmet} to player's helmet
	set {items::%uuid of player%::boots} to player's boots
	send "Stored your helmet and boots."

command /outfit:
	executable by: players
	permission: skript.example.outfit
	trigger:
		give player {items::%uuid of player%::*} # gives the contents of the list
		clear {items::%uuid of player%::*} # clears this list
		send "Gave you the helmet and boots you joined with."
Using uuid of player ensures variables work even if a player changes their name.

Setting Variables

set {variable} to "value"
set {balance::%uuid of player%} to 100
set {timer} to now
set {homes::%uuid of player%::home} to player's location

Checking Variables

Test if a variable is set:
if {timer} is set:
	send "Timer is active"
else:
	send "Timer has never been set"

if {homes::%uuid of player%::%arg-1%} is set:
	teleport player to {homes::%uuid of player%::%arg-1%}
else:
	send "You have no home named <green>%arg-1%<reset>."

Variable Scope

  • Only exist within the current trigger
  • Not saved to database
  • Deleted when trigger finishes
  • Perfect for calculations and temporary data
  • Faster than global variables
  • Persist across server restarts
  • Saved to database file
  • Accessible from any script
  • Used for player data, statistics, configurations
  • Can slow down server if overused

Complete Examples

Home System

command /home <text> [<text>]:
	description: Set, delete or travel to your home.
	usage: /home set/remove <name>, /home <name>
	permission: skript.example.home
	executable by: players
	trigger:
		if arg-1 is "set":
			if arg-2 is set:
				set {homes::%uuid of player%::%arg-2%} to player's location
				send "Set your home <green>%arg-2%<reset> to <grey>%location of player%<reset>" to player
			else:
				send "You must specify a name for this home." to player
		else if arg-1 is "remove":
			if arg-2 is set:
				delete {homes::%uuid of player%::%arg-2%}
				send "Deleted your home <green>%arg-2%<reset>" to player
			else:
				send "You must specify the name of this home." to player
		else if arg-2 is set:
			send "Correct usage: /home set/remove <name>" to player
		else if {homes::%uuid of player%::%arg-1%} is set:
			teleport player to {homes::%uuid of player%::%arg-1%}
		else:
			send "You have no home named <green>%arg-1%<reset>." to player

Damage Tracker

on damage:
	victim is a player
	if the victim has permission "skript.example.damage":
		cancel the event
	else:
		send "Ouch! You took %damage% damage." to the victim
		add damage to {damage::%uuid of victim%::taken}
		if the attacker is a player:
			add damage to {damage::%uuid of attacker%::dealt}

Shopping List

command /shoppinglist:
	permission: skript.example.list
	trigger:
		add "bacon" to {_shopping list::*}
		add "eggs" to {_shopping list::*}
		add "oats" and "sugar" to {_shopping list::*}
		send "You have %size of {_shopping list::*}% things in your shopping list:"
		loop {_shopping list::*}:
			send "%loop-index%. %loop-value%"
		send "You bought some %{_shopping list::1}%!"
		remove "bacon" from {_shopping list::*}
		send "Removing bacon from your list."
		send "You now have %size of {_shopping list::*}% things in your shopping list."

Database Storage

Global variables are stored in:
plugins/Skript/variables.csv
Don’t manually edit the variables file while the server is running. Use /skript reload or commands to modify variables.

Variable Types Reference

Variables can store any Skript type:
  • Text: {name} = “Steve”
  • Numbers: {balance} = 100
  • Players: {target} = player
  • Locations: {spawn} = location at 0, 64, 0
  • Items: {item} = diamond sword
  • Times: {timer} = now
  • Lists: {list::*} = multiple values

Performance Tips

Use Local Variables

Local variables are much faster than global variables for temporary data

Clean Up Old Data

Delete variables when no longer needed to keep the database small

Batch Operations

Modify multiple variables at once instead of in separate events

Avoid Excessive Nesting

Deep variable nesting (many ::) can slow down lookups

Next Steps

Functions

Pass variables to reusable functions

Commands

Use variables in custom commands

Build docs developers (and LLMs) love