SimplyStore Tutorial

SimplyStore Tutorial
SimplyStore is a data storing system for games. The goal is to be as easy and intuitive as possible. This is a simple tutorial that explains how to use SimplyStore through examples.

Modifying Values
In this section of the tutorial, we’re going to program a “Time” score that increases every second and saves with SimplyStore.

When modifying values, there are a few things you need to do:

  1. To start off, you’ll need to get a player, then wait for their leaderstats. In this case, we get players when they join the game using the Players.PlayerAdded event.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
    local leaderstats = player:WaitForChild("leaderstats")
end)
  1. If the item isn’t always there, either end the function or create the item. To make sure an item is in leaderstats, you can also add it to the default data. In this case, lets not do that:
local function addTime(amount, leaderstats)
    local timeValue = leaderstats:FindFirstChild("Time")
    --If there isn't a "Time" IntValue then we make a new one.
    if not timeValue then
        timeValue  = Instance.new("IntValue")
        timeValue.Name = "Time"
        timeValue.Parent = leaderstats
    end
    --From this point on, timeValue exists in every case.
    timeValue.Value += amount
end

Notice how we handled the situation where there isn’t a “Time” IntValue already created by creating a new one.

  1. Next, lets put that code together and use the function we made:
local Players = game:GetService("Players")

local function addTime(amount, leaderstats)
    local timeValue = leaderstats:FindFirstChild("Time")
    --If there isn't a "Time" IntValue then we make a new one.
    if not timeValue then
        timeValue  = Instance.new("IntValue")
        timeValue.Name = "Time"
        timeValue.Parent = leaderstats
    end
    --From this point on, timeValue exists in every case.
    timeValue.Value += amount
end

Players.PlayerAdded:Connect(function(player)
    local leaderstats = player:WaitForChild("leaderstats")
    --We can use the function we made above to add some time every second
    while player do
        addTime(1, leaderstats)
        task.wait(1)
    end
end)

And that’s it! Using SimplySave to store leaderstats, that’s the full code to create a saving time score and a quick demo of modifying variables.

You can check out the code in action here:
Time Score Example - Roblox

Back To Top

Representing Data
In this section, we’re going to look at ways to represent complex data that’s often stored in data stores.

Data Guide:

  • Inventories:
    • Single Item:
      • Container of containers, where each sub container represents an item.
      • Container of BoolValues, where each BoolValue’s Value represents whether a player has an item.
      • StringValue, where commas separate item names (not recommended).
    • Multi Item:
      • Container of IntValues, where each IntValue’s Name describes what item and the IntValue’s Value describes how many.
  • Buildings:
    • Container of CFrame values, where each CFrame’s Name describes what model and the CFrame’s Values describes the location (possibly relative to a build plate or the world).

This section will be expanded on.

Back To Top

Versioning

Back To Top

Back To Top

4 Likes