KeyValueStore
A place to save small values under names you choose, which you get from data.store.
Gives back the value that is saved in the store for a key.
example
local motd = settings:get("motd")
Use it forloading the welcome message that each server shows when it starts.
Saves a value for a key, and saving nil removes the key.
example
settings:set("motd", "Welcome!")
Use it forchanging the welcome message that every server of your game reads.
keyThe key.
valueThe new value, at most 64 KB as JSON. Nil removes the key.
KeyValueStore:update
method#Gives a key's value to a function you write, and saves whatever it returns.
KeyValueStore:update(key: string, transform: (any) -> any) -> any
example
settings:update("visits", function(value) return (value or 0) + 1 end)
Use it forcounting total visits safely while many servers add to the same number at once.
keyThe key.
transformGets the value and returns the new one, not nil. It can run more than once, and must not yield.
KeyValueStore:remove
method#Deletes the saved value for a key from the store.
example
settings:remove("motd")
Use it forclearing an event message once the event is over, so players stop seeing it.