PlayerTempDataService
A module to manage the loading and unloading of player data. Built With ProfileService
Setting Up
- To get started you must first edit
SETTINGS.SaveStructure
inPlayerTempDataService
. Add and remove variables ofSaveStructure
as you see fit your needs.Ran into an issue?, Troubleshooting
Basic Usage
--!strict
--[[
{C.G.T}
-[TestService]---------------------------------------
A module for testing other modules
Members:
Functions:
Members [ClassName]:
Methods [ClassName]:
--]]
local SETTINGS = {}
----- Loaded Modules -----
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Knit = require(ReplicatedStorage.Packages.knit)
----- Module Table -----
local TestService = Knit.CreateService({ Name = "TemplateService" })
----- Private Variables -----
----- Private functions -----
----- Public -----
----- Initialize & Connections -----
function TestService:KnitStart()
local player_temp_data_service = Knit.GetService("PlayerDataService")
local player = Players:GetPlayers()[1] or Players.PlayerAdded:Wait()
player_temp_data_service:GetDataReplica(player):andThen(function(DataReplica)
DataReplica:SetValue("SomeData", DataReplica.Data.SomeData + 100)-- The value you're changing has to have been added in your save structure
end)
end
return TestService
--!strict
--[[
{C.G.T}
-[TestController]---------------------------------------
A module for testing other modules
Members:
Functions:
Members [ClassName]:
Methods [ClassName]:
--]]
local SETTINGS = {}
----- Loaded Modules -----
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Knit = require(ReplicatedStorage.Packages.knit)
local ReplicaController = require(game.ReplicatedStorage.Packages.replicaservice)
----- Module Table -----
local TestController = Knit.CreateController({ Name = "TestController" })
----- Private Variables -----
----- Private functions -----
----- Public -----
----- Initialize & Connections -----
function TestController:KnitStart()
ReplicaController.ReplicaOfClassCreated("PlayerTempData", function(replica)
if replica.Tags.Player == Players.LocalPlayer then
replica:ListenToChange("SomeData", function()
print("SomeData Changed")
--Do Something when SomeData changes
end)
end
end)
end
return TestController
Members
-
Datas
(Yes I am aware that data is a plural) -
DataReplicas