Store and Retrieve Player Data with Variables
Understanding Skript Variables
Variables let you remember information about players, like their level, coins, or playtime. Skript supports both temporary variables (lost on server restart) and persistent variables (saved to disk).
Creating and Using Variables
Temporary variables are simple:
`
command /setcoins <number>:
trigger:
set {coins::%player%} to argument 1
send "You now have %{coins::%player%}% coins" to player
`
The %player% part makes each player have their own coin count. Retrieve it anytime with {coins::%player%}.
Persistent Storage
For data that survives server restarts, use YAML files:
`
command /balance:
trigger:
send "Your balance: %{balance::%player's uuid%}%" to player
`
Skript automatically saves these variables. Use player's uuid instead of just the player name to handle name changes correctly. Variables are incredibly flexible—use them for points, cooldowns, settings, or any custom data your server needs.