# This example listens for players joining and leaving.# Alters the default message when they do.on join: set the join message to "Oh look, %player% joined! :)"
Here’s a complete example from the Skript source showing multiple concepts:
## A simple broadcasting function example.# This demonstrates how to declare and run a simple function.#function say_message(message: text): broadcast {_message} # our message argument is available in `{_message}`.on first join: wait 1 second say_message("Welcome, %player%!") # Runs the `say_message` function.## An example of a function with multiple parameters and a return type.# This demonstrates how to return a value and use it.#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} # Gives this value to the code that called the function.command /appleexample: permission: skript.example.apple trigger: send "Giving you an apple!" set {_item} to give_apple("Banana", 4) give player {_item}
Always use tabs for indentation, not spaces. Mixing tabs and spaces will cause syntax errors.