Basically, during the testing of a game, I messed up my inventory which causes my inventory to stop working how it should. One fix we found, was by resetting the data store for everyone. But due the amount of save data, we reverted back so everyone kept their items. How would I go about only changing one persons data store so it loads clear and saves as a different loader. - What I mean by that is, all the other players save and load how they normally are, but the other player (me) saves and loads with a different store to allow my inventory to work again?
local ServerScriptService = game:GetService("ServerScriptService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local ServerStorage = game:GetService("ServerStorage") local Players = game:GetService("Players") local PlayerSaves = game:GetService("DataStoreService"):GetDataStore("PlayerSavs") local Key = 'GSSSPARTA1'-- Last Version Spartan 5.0.0 [UPDATED 10/04/19]" local GameItems = ReplicatedStorage.Items local Modules = ReplicatedStorage["Module_Engine"]["Common_Function_Modules"] local DropItemAtCharacter = require(Modules.DropItemAtCharacter) local PlayerStats = Instance.new("Configuration", ReplicatedStorage) PlayerStats.Name = "PlayerStats" local TableOfContents = { ["UserSettings"] = { ["MusicOn"] = {"true", "BoolValue"}, ["Tutorial"] = {"true", "BoolValue"} }, ["UserStats"] = { ["Experience"] = {0, "IntValue"}, ["ExperienceAim"] = {100, "IntValue"}, ["Level"] = {0, "IntValue"}, ["CharacterName"] = {"NoName", "StringValue"}, ["WalkSpeed"] = {16, "NumberValue", {"DefaultValue", "IntValue", 16}}, ["Health"] = {100, "NumberValue", {"MaxValue", "NumberValue", 100}}, ["Hunger"] = {100, "NumberValue", {"MaxValue", "NumberValue", 100}}, ["Thirst"] = {100, "NumberValue", {"MaxValue", "NumberValue", 100}}, ["Alcohol"] = {0, "NumberValue", {"MaxValue", "NumberValue", 100}}, ["AlcoholPhase"] = {"NumberValue","NumberValue"}, ["Stamina"] = {100, "NumberValue", {"MaxValue", "NumberValue", 100}}, ["ItemCapacity"] = {5, "IntValue", {"DefaultValue", "IntValue", 5}}, ["UtilityCapacity"] = {5, "IntValue", {"DefaultValue", "IntValue", 5}}, -- Coins, Ores ["Ore_Copper"] = {5, "IntValue", {"MaxValue", "IntValue", 50}}, ["Ore_Gold"] = {5, "IntValue", {"MaxValue", "IntValue", 50}}, ["Ore_Iron"] = {5, "IntValue", {"MaxValue", "IntValue", 50}}, ["Ore_Silver"] = {5, "IntValue", {"MaxValue", "IntValue", 50}}, ["Ore_Coal"] = {5, "IntValue", {"MaxValue", "IntValue", 50}}, -- Other resources ["Cloth"] = {5, "IntValue", {"MaxValue", "IntValue", 50}}, ["Leather"] = {5, "IntValue", {"MaxValue", "IntValue", 50}}, ["Wood"] = {5, "IntValue", {"MaxValue", "IntValue", 50}}, ["Seashell"] = {5, "IntValue", {"MaxValue", "IntValue", 50}}, }, ["Items"] = { -- By default, enter in here the items that users may recieve on first-time joining ["ToolIronAxe"] = {0, "IntValue"}, ["ToolIronPickaxe"] = {0, "IntValue"}, }, ["Utility"] = { -- By default, enter in here the items that users may recieve on first-time joining ["ClothingTunicStarter"] = {0, "IntValue"}, }, ["Primary"] = { -- By default, enter in here the items that users may recieve on first-time joining ["WeaponStarter"] = {0, "IntValue"}, }, ["Secondary"] = { -- By default, enter in here the items that users may recieve on first-time joining }, ["Backpack"] = { -- By default, enter in here the items that users may recieve on first-time joining }, } local function ItterateThroughString(String) local Table = {} for a in string.gmatch(String, "[^,]+") do table.insert(Table, a) end return Table end local function SaveData(Player, RemoveOnExit) if Player then local LocalFolder = PlayerStats:FindFirstChild("Data_" .. Player.Name) if LocalFolder then local Table = {} for _,Sub in pairs(LocalFolder:GetChildren()) do local Contents = {} for _,x in pairs(Sub:GetChildren()) do local Val = {} if Sub.Name == "Items" and Contents[x.Name] then Val = {x.Name, x.className, tostring(Contents[x.Name][1]+1)} else -- Name, Class, Value if x:IsA("Vector3Value") then Val = {x.Name, x.className, tostring(x.Value.X) .. "," .. tostring(x.Value.Y) .. "," .. tostring(x.Value.Z)} elseif x:IsA("CFrameValue") then Val = {x.Name, x.className, tostring(x.Value.X) .. "," .. tostring(x.Value.Y) .. "," .. tostring(x.Value.Z)} elseif x:IsA("BoolValue") then Val = {x.Name, x.className, tostring(x.Value)} elseif x:IsA("Color3Value") then Val = {x.Name, x.className, tostring(x.Value.r) .. "," .. tostring(x.Value.g) .. "," .. tostring(x.Value.b)} elseif x:IsA("StringValue") then Val = {x.Name, x.className, x.Value} else Val = {x.Name, x.className, x.Value} end end Contents[Val[1]] = {Val[3], Val[2], TableOfContents[Sub.Name][Val[1]] and TableOfContents[Sub.Name][Val[1]][3] or nil} end -- print("----> Saved Folder " .. Sub.Name) Table[Sub.Name] = Contents end PlayerSaves:SetAsync(Key .. Player.userId, Table) print("Successfully saved") if RemoveOnExit then LocalFolder:Destroy() end end end end Players.PlayerAdded:connect(function(Player) if Player then local LocalPlayerData = Instance.new("Configuration") LocalPlayerData.Name = "Data_" .. Player.Name local PlayerData = PlayerSaves:GetAsync(Key .. Player.userId) if not PlayerData then PlayerData = TableOfContents end for Folder, Contents in pairs(PlayerData) do local SubFolder = Instance.new("Configuration", LocalPlayerData) SubFolder.Name = Folder for NewValue, SubContents in pairs(Contents) do if NewValue ~= "DataContents" then if GameItems:FindFirstChild(NewValue) then for i = 0, tonumber(SubContents[1]) do local Val = Instance.new(SubContents[2], SubFolder) Val.Name = NewValue Val.Value = 0 end else local Val = Instance.new(SubContents[2], SubFolder) Val.Name = NewValue if SubContents[3] ~= nil then local DefaultOrMaxValue = Instance.new(SubContents[3][2], Val) DefaultOrMaxValue.Name = SubContents[3][1] DefaultOrMaxValue.Value = SubContents[3][3] end -- Can't save instances with DataStore, so we need to filter through and then re-make them based on the values if SubContents[2] == "Color3Value" then local TableOfVectors = ItterateThroughString(SubContents[1]) Val.Value = Color3.new(TableOfVectors[1], TableOfVectors[2], TableOfVectors[3]) elseif SubContents[2] == "Vector3Value" then local TableOfVectors = ItterateThroughString(SubContents[1]) Val.Value = Vector3.new(TableOfVectors[1], TableOfVectors[2], TableOfVectors[3]) elseif SubContents[2] == "CFrameValue" then local TableOfVectors = ItterateThroughString(SubContents[1]) Val.Value = CFrame.new(TableOfVectors[1], TableOfVectors[2], TableOfVectors[3]) elseif SubContents[2] == "BrickColorValue" then Val.Value = BrickColor.new(SubContents[1]) elseif SubContents[2] == "BoolValue" then if SubContents[1] == "false" then Val.Value = false else Val.Value = true end else Val.Value = SubContents[1] end end end end end LocalPlayerData.Parent = PlayerStats end end) Players.PlayerRemoving:connect(function(Player) SaveData(Player, true) end) function SaveAll() for _,Player in pairs(Players:GetPlayers()) do coroutine.wrap(function() SaveData(Player) end)() end end game.OnClose = function() print("Game Closing") SaveAll() print("Done") end while wait(120) do SaveAll() end
Thank you!