This guide will walk you through creating your first Skript - a simple join/leave message system with a custom command. By the end, you’ll understand the basics of events, commands, and variables.
Navigate to your server’s plugins/Skript/scripts/ folder and create a new file called welcome.sk.
Script files must have the .sk extension to be recognized by Skript.
2
Add welcome messages
Open welcome.sk in your text editor and add the following code:
# Welcome players with custom join/leave messageson join: set the join message to "Oh look, %player% joined! :)"on quit: set the quit message to "Oh no, %player% left! :("
This script listens for join and quit events and customizes the messages shown to all players.
3
Load the script
In your server console or as an admin in-game, run:
/skript reload welcome
You should see a message confirming the script loaded successfully. Now try disconnecting and rejoining - you’ll see your custom messages!
Let’s expand our script with a command that allows players to see how long they’ve been playing.Add this to your welcome.sk file:
# Track when players join and let them check their playtimeon join: set the join message to "Oh look, %player% joined! :)" set {join.time::%uuid of player%} to nowon quit: set the quit message to "Oh no, %player% left! :("command /playtime: description: Check how long you've been playing this session executable by: players trigger: if {join.time::%uuid of player%} is set: send "You've been playing for %time since {join.time::%uuid of player%}%!" else: send "Unable to determine your playtime."
Reload the script:
/skript reload welcome
Now players can use /playtime to see how long they’ve been online!
Let’s create a new script called heal.sk with command arguments and permissions:
command /heal [<player>]: description: Heal yourself or another player permission: skript.heal permission message: You don't have permission to use this command! executable by: players trigger: if arg-1 is set: # Heal another player (requires admin permission) if player has permission "skript.heal.others": heal arg-1 set the food level of arg-1 to 10 send "You healed %arg-1%!" to player send "You were healed by %player%!" to arg-1 else: send "You don't have permission to heal others!" else: # Heal yourself heal player set the food level of player to 10 send "You have been healed!"
This command:
Accepts an optional player argument
Requires the skript.heal permission
Allows healing others with skript.heal.others permission
Here’s a complete working script that gives new players a starter kit:
# Give new players a welcome kiton first join: broadcast "Welcome %player% to the server for the first time!" # Give starter items give player a stone sword named "Starter Sword" give player 16 cooked beef give player 32 oak planks # Set spawn point set the player's spawn point to location(0, 65, 0, world "world") # Send welcome message send "" to player send "&6&l========== WELCOME! ==========" to player send "" to player send "&eThank you for joining!" to player send "&eType &a/help &eto get started." to player send "" to player send "&6&l==============================" to player send "" to player
Save this as starterkit.sk and reload:
/skript reload starterkit
The & symbol followed by a color code (like &6 for gold or &e for yellow) adds color to text. Use &l for bold formatting.
These examples are adapted from Skript’s official example scripts found in the source repository:
# Custom damage handlingon damage: victim is a player if the victim has permission "skript.example.damage": cancel the event # Stops the default behaviour 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}
Debugging: If your script doesn’t work, check the server console for error messages. Skript provides detailed error information including line numbers.
Testing: Use /skript reload <scriptname> frequently while developing. You don’t need to restart your server to test changes!
Be careful with loops: Infinite loops can freeze your server. Always include a way to exit loops or use delays in loops that run many times.