Skip to main content
Conditions are logical tests that return true or false. They control the flow of your scripts by determining when code should execute.

Basic Condition Syntax

Conditions are used with if, else if, and else statements:
if <condition>:
	# code to run if true
else if <condition>:
	# code to run if first is false and this is true
else:
	# code to run if all conditions are false

Comparison Operators

Compare values using these operators:
if {_value} is 5:
if {_text} is "hello":
if player is attacker:

if {_value} is not 10:
if player is not attacker:

Logical Operators

Combine multiple conditions:
# AND - both must be true
if player has permission "skript.admin" and {_balance} > 100:

# OR - at least one must be true
if player is holding a diamond sword or player is holding a diamond axe:

# NOT - inverts the condition
if player does not have permission "skript.example.damage":

Common Conditions

# Permissions
if player has permission "skript.example.item":

# Inventory
if player is holding a diamond pickaxe:
if player's inventory contains 10 emeralds:

# State
if player is online:
if player is in world "world_nether":
if player is flying:

Inline Conditions

Use conditions directly in events to filter when they trigger:
on inventory click:
	event-slot is the helmet slot of player
	inventory action is place all or nothing
	player has permission "skript.example.helmet"
	cursor slot of player is custom helmets
	# All conditions must be true for code to execute
	cancel the event
	set {_old helmet} to the helmet of player
	set the helmet of player to the cursor slot of player
	set the cursor slot of player to {_old helmet}
Conditions placed directly after an event line act as filters. The event code only runs if all conditions are true.

Complex Conditions

Combine multiple conditions for complex logic:
command /item <items>:
	permission: skript.example.item
	executable by: players
	trigger:
		if player has permission "skript.example.item.all":
			give argument to player
		else:
			loop argument:
				if loop-item is not blacklisted:
					give loop-item to player
				else:
					send "<red>%loop-item%<reset> is blacklisted and cannot be spawned." to player

Nested Conditions

Conditions can be nested for complex decision trees:
command /home <text> [<text>]:
	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

While Loops with Conditions

Conditions control while loops:
command /whileexample:
	permission: skript.example.while
	trigger:
		set {_number} to 5
		while {_number} is greater than 0:
			send "The number is %{_number}%"
			remove a random number between 0 and 2 from {_number}
		send "Finished counting down."
		
		while true is true: # this will run forever
			add "banana" to {_list::*}
			if size of {_list::*} is 10:
				exit loop
		send "The list has %size of {_list::*}% bananas."
Be careful with while loops. Without an exit condition, they can freeze your server. Always include a way to break out of the loop.

Chance Conditions

Execute code based on probability:
on death:
	victim is a zombie
	chance of 10%:
		drop 1 diamond at victim's location

Condition Categories

  • <player> has permission <text>
  • <player> is holding <item>
  • <player> is online/offline
  • <player> is in <world>
  • <player> is flying/sneaking/sprinting
  • <player> can fly
  • <player> can see <entity>
  • <block> is <type>
  • <block> is solid/transparent
  • <block> is powered
  • <block> is passable
  • <entity> is a <type>
  • <entity> is alive/dead
  • <entity> is on fire
  • <entity> is in water
  • <entity> can pick up items
  • <value> is <value>
  • <number> > / < / >= / <= <number>
  • <text> contains <text>
  • <list> contains <value>
  • <variable> is set/not set
  • chance of <number>%
  • <time> is before/after <time>
  • <weather> is <weather>

Complete Example

Here’s a real example from the Skript source demonstrating condition usage:
#
# This example cancels damage for players if they have a specific permission.
# If they don't, tell them how much damage they took.
#

on damage:
	victim is a player
	if the victim has permission "skript.example.damage":
		cancel the event # Stops the default behaviour - the victim taking damage.
	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}

Best Practices

Keep It Simple

Break complex conditions into multiple if statements for readability

Check First

Validate inputs and check permissions before performing actions

Fail Fast

Put the most restrictive conditions first to exit early

Use Else

Provide feedback with else blocks when conditions fail

Next Steps

Expressions

Learn about values used in conditions

Variables

Store and check values with variables

Build docs developers (and LLMs) love