Skip to content

Count wipes in the save

Keep a tally of wipes per island in the player’s save slot.

main.luau
if not mod.is_server then
return
end
-- { ["3"] = 2, ["5"] = 1 }: wipes by victim island. JSON keys are text.
mod.on("island_wiped", function(e)
local tally = mod.save.get("tally") or {}
local key = tostring(e.to)
tally[key] = (tally[key] or 0) + 1
mod.save.set("tally", tally)
mod.log("island", key, "wiped", tally[key], "times")
end)
  • mod.save belongs to the server VM, so the client returns early.
  • Save data goes through JSON, where keys are text. tostring(e.to) makes the island number a key that comes back the same way.
  • get returns a copy; change it, then set it again.

The longer version: Save data.