Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to save data in serverstorage and with tables?

Asked by 4 years ago
Edited 4 years ago

I want to do this because people say this is the best way and also, I used to save data in the player but I see people recommending that it is not be used. Can someone help me or provide links with this? This is my incomplete attempt at this:

I have 2 datas: Novas and Level

-- Variables

local Players = game:GetService("Players") -- get service
local DataStoreService = game:GetService("DataStoreService") -- get service
local DataStoreKey = "qwerty" -- change this to reset data
local Data = DataStoreService:GetDataStore(DataStoreKey)


local StarterData = { -- value of the data when a player first joins the game
    ["Novas"] = 100;
    ["Level"] = 1
}

-- Code

Players.PlayerAdded:Connect(function(player) -- event when player joins
    local key = "User_"..player.UserId -- player key
end)

Players.PlayerRemoving:Connect(function(player) -- event when player leaves
    local key = "User_"..player.UserId -- player key
end)

Answer this question