Hello! I've been trying to make a datastore system, but something is going wrong. Whenever I store my data, it gives a weird number. For instance, when I join the game and set up Class-D experience to 4, Security Department experience to 6, clearance level to 7, and global experience to 3 and leave, this is what it prints: 0_0_0_0_ In theory, it should print 3_7_4_6_, but it doesn't.
--[[ // Description Manage all main Data by storing it and gathering it. Data is stored in strings and decrypted using string.split() ]] --// Services local DataStoreService = game:GetService("DataStoreService") local PlayerService = game:GetService("Players") --// Variables local DataStoreKey = "DevelopmentStage 3/5/2022 #4" -- Change to erase or restore data (global) local DataStore = DataStoreService:GetDataStore(DataStoreKey) --// Logic function FolderGatherCreate(playerModel) -- returns the folders if present, if not it creates the folders and then returns them. if playerModel:FindFirstChild("Data") ~= nil then -- Data folders are present return playerModel.Data else -- Data folders are not present --//Instancing local DataFolder = Instance.new("Folder") local TeamData = Instance.new("Folder") local GlobalExperience = Instance.new("IntValue") local KeycardClearanceLevel = Instance.new("IntValue") local ClassDFolder = Instance.new("Folder") local ClassDExperience = Instance.new("IntValue") local SecurityDeptFolder = Instance.new("Folder") local SecurityDeptExperience = Instance.new("IntValue") --//Properties DataFolder.Name = "Data" DataFolder.Parent = playerModel GlobalExperience.Name = "GlobalExperience" GlobalExperience.Parent = DataFolder GlobalExperience.Value = 0 KeycardClearanceLevel.Name = "ClearanceLevel" KeycardClearanceLevel.Parent = DataFolder KeycardClearanceLevel.Value = 0 ClassDFolder.Name = "ClassD" ClassDFolder.Parent = DataFolder ClassDExperience.Name = "Experience" ClassDExperience.Parent = ClassDFolder ClassDExperience.Value = 0 SecurityDeptFolder.Name = "SecurityDepartment" SecurityDeptFolder.Parent = DataFolder SecurityDeptExperience.Name = "Experience" SecurityDeptExperience.Parent = SecurityDeptFolder SecurityDeptExperience.Value = 0 --//Misc return DataFolder end end PlayerService.PlayerAdded:Connect(function(playerJoined) -- Runs when a player joins the game --// Variables local playerID = playerJoined.UserId local DataFolder = FolderGatherCreate(playerJoined) --// Logic task.wait(0.1) -- Give time for Datastores to load if DataStore:GetAsync(playerID) ~= nil then --// Variables local DataGathered = DataStore:GetAsync(playerID) local splits = string.split(DataGathered[1],"_") --//Apply Changes DataFolder.GlobalExperience.Value = tonumber(splits[1]) DataFolder.ClearanceLevel.Value = tonumber(splits[2]) DataFolder.ClassD.Experience.Value = tonumber(splits[3]) DataFolder.SecurityDepartment.Experience.Value = tonumber(splits[4]) end end) PlayerService.PlayerRemoving:Connect(function(playerRemoved) -- Runs when a player leaves the game local DataFolder = FolderGatherCreate(playerRemoved) local StoreString = tostring(DataFolder.GlobalExperience.Value) .. "_" .. tostring(DataFolder.ClearanceLevel.Value) .. "_" .. tostring(DataFolder.ClassD.Experience.Value) .. "_" .. tostring(DataFolder.SecurityDepartment.Experience.Value) .. "_" print(StoreString) -- for debugging. DataStore:SetAsync(playerRemoved.UserId, {StoreString,true}) end)