Basic Use

After instilation require the module and run this command:

local store = TraditionalSave.GetStore("PlayerData", {})

Then when a player joins you need to create a profile for that player, which can be done as follows.

Players.PlayerAdded:Connect(function(player)
    local PlayerProfile = Store:NewPlayer(player) -- By default this will automaticly be cleaned up on player leave.
    
    --PlayerProfile will equal false if a session is already active.
    if PlayerProfile == false then
	player:Kick("Currently Active Session. Please wait a bit and rejoin!")
	return
    end
end)

Before you can read player data, you need to first load into a file, which can be done with using PlayerProfile:LoadFile() then finally, so load the data we run PlayerProfile:GetCurrent() so we need to add that to the loader like so.

Players.PlayerAdded:Connect(function(player)
    local PlayerProfile = Store:NewPlayer(player) -- By default this will automaticly be cleaned up on player leave.
    
    --PlayerProfile will equal false if a session is already active.
    if PlayerProfile == false then
	player:Kick("Currently Active Session. Please wait a bit and rejoin!")
	return
    end
    
    PlayerProfile:LoadFile(1) --This loads the player into the first file
    
    local FileData = PlayerProfile:GetCurrent() --This returns the data to the file.
end)

Whenever the save state in your game is met, you can fire PlayerProfile:SaveCurrent()to mark the data to be saved in the next save cycle.

Players.PlayerAdded:Connect(function(player)
    local PlayerProfile = Store:NewPlayer(player) -- By default this will automaticly be cleaned up on player leave.
    
    --PlayerProfile will equal false if a session is already active.
    if PlayerProfile == false then
	player:Kick("Currently Active Session. Please wait a bit and rejoin!")
	return
    end
    
    PlayerProfile:LoadFile(1) --This loads the player into the first file
    
    local FileData = PlayerProfile:GetCurrent() --This returns the data to the file.
    
    task.wait(5)
    
    PlayerProfile:SaveCurrent()
end)

Last updated