Skip to main content
Expressions are pieces of code that represent values. They can be numbers, text, players, items, locations, or any other data type in Skript.

What are Expressions?

Expressions provide values that you can:
  • Store in variables
  • Use in conditions
  • Pass to effects
  • Return from functions
Unlike effects, expressions don’t perform actions—they represent data.

Basic Expressions

player # The player who triggered the event
player's name
player's health
player's location
player's inventory
player's helmet
uuid of player

String Expressions

Work with text using string expressions:
command /greet <text>:
	trigger:
		set {_name} to arg-1
		set {_message} to "Hello, %{_name}%!"
		send {_message} to player

String Formatting

Embed expressions in strings with %expression%:
send "Welcome, %player%!" to player
send "You have %player's health% health." to player
send "Location: %location of player%" to player

Item Expressions

Work with items and inventories:
command /appleexample:
	permission: skript.example.apple
	trigger:
		send "Giving you an apple!"
		set {_item} to give_apple("Banana", 4)
		give player {_item}

function give_apple(name: text, amount: number) :: item:
	set {_item} to an apple
	set the name of {_item} to {_name}
	set the item amount of {_item} to {_amount}
	return {_item}

Item Properties

name of {_item}
item amount of {_item}
durability of {_item}
lore of {_item}
enchantments of {_item}

Location Expressions

Work with positions in the world:
player's location
location of event-block
location at 0, 64, 0 in world "world"
spawn of world "world"

# Relative locations
location 5 meters above player
location 10 blocks in front of player

List Expressions

Expressions that return multiple values:
all players
all players in world "world"
all players in radius 10 of player

Loop Values

Special expressions available inside loops:
loop all players:
	loop-player # The current player in the loop
	loop-index # The position in the loop (1, 2, 3...)
	
	if loop-player has permission "skript.example.apple":
		give loop-player an apple named "Potato"

loop {_items::*}:
	loop-value # The current value
	loop-index # The position
	send "%loop-index%. %loop-value%"

Time Expressions

Work with dates and durations:
now # Current date and time
5 seconds
10 minutes
1 hour
2 days

# Time calculations
now + 1 day
time since {timer}

if {timer} is set:
	send "This command was last run %time since {timer}% ago."
set {timer} to now

Argument Expressions

Access command arguments:
command /home <text> [<text>]:
	trigger:
		arg-1 # First argument (required)
		arg-2 # Second argument (optional)
		
		if arg-1 is "set":
			if arg-2 is set:
				set {homes::%uuid of player%::%arg-2%} to player's location
Arguments are numbered starting at 1. arg-1 is the first argument, arg-2 is the second, etc.

Property Expressions

Get and set properties of objects:
player's health
player's max health
player's food level
player's gamemode
helmet of player
name of {_item}

Math Operations

Perform calculations:
set {_result} to 10 + 5 # 15
set {_result} to 20 - 8 # 12
set {_result} to 4 * 6 # 24
set {_result} to 15 / 3 # 5

add 5 to {_number}
remove 3 from {_number}

set {_random} to a random integer between 1 and 100
set {_random} to a random number between 0 and 2

Complete Example

Here’s a real example from the Skript source showing expression usage:
#
# This example stores a time-stamp in the global `{timer}` variable.
# This variable is accessible everywhere, and will be saved when the server stops.
#
# The `{_difference}` variable is local and is different for each use of the command.
#

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

Type Conversion

Convert between types:
"%number%" # Convert to text
number parsed as "%text%" # Convert text to number
location("%text%") # Parse location from text

Expression Categories

  • player / attacker / victim
  • player's name / display name
  • player's health / max health
  • player's location / world
  • player's inventory
  • uuid of player
  • player's gamemode
  • <item>
  • name of <item>
  • item amount of <item>
  • durability of <item>
  • lore of <item>
  • enchantments of <item>
  • <number> of <item>
  • location of <entity/block>
  • <entity>'s location
  • spawn of <world>
  • location at <x>, <y>, <z>
  • x/y/z coordinate of <location>
  • world of <location>
  • now
  • <number> seconds/minutes/hours/days
  • time since <date>
  • time in <world>
  • real time
  • <number> + <number>
  • <number> - <number>
  • <number> * <number>
  • <number> / <number>
  • random integer between <number> and <number>
  • size of <list>
  • all players
  • all entities
  • blocks in radius <number> of <location>
  • <variable>::* (list variable)
  • loop-value / loop-index

Common Patterns

# Store in variables
set {_value} to player's health
set {homes::%uuid of player%::home} to player's location

# Use in conditions
if player's health is less than 5:
if {_list::*} contains "apple":
Expressions can be combined and nested. For example: name of helmet of player gets the name of the item in the player’s helmet slot.

Next Steps

Variables

Learn how to store expression values

Functions

Create reusable code with return values

Build docs developers (and LLMs) love