MODULE
local Module = {Data = {}} local DataStoreService = game:GetService("DataStoreService"); local KeyPrefix = "data_user#"; local DataStore = DataStoreService:GetDataStore("TestData_v.15"); local DataTemplate = { Money = 300; Level = 1; }; local function GetKey(id) return KeyPrefix .. id; end; Module.InitializeData = function(plr) local Key = GetKey(plr.UserId); Module.Data[plr] = DataStore:GetAsync(Key) or DataTemplate; end; Module.ConcludeData = function(plr) local Key = GetKey(plr.UserId); local Data = Module.Data[plr]; if Data and Data ~= nil then DataStore:SetAsync(Key, Data); Data = nil; end; end; return Module;
SCRIPT
local DataModule = require(script.Parent:WaitForChild("DataModule")); game.Players.PlayerAdded:Connect(function(Player) DataModule.InitializeData(Player); end); game.Players.PlayerRemoving:Connect(function(Player) DataModule.ConcludeData(Player); end);
This is what I'm having trouble with. When in game and the data is changed, it works n all, but when i leave and rejoin, i have the default data.. It's tough because this used to be my method and worked like 100% of the time, and it just recently stopped.. Roblox did an update on studio not too long ago, could it be that??