Code below won't load data, no errors, I have no idea what's going on.
local dataStoreService = game:GetService("DataStoreService") local cubeDataStore = dataStoreService:GetDataStore("Cubes") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" local cubesmade = Instance.new("IntValue",leaderstats) cubesmade.Name = "Cubes" cubesmade.Value = 0 local playerUserId = "player_"..player.UserId local cubeData local success, errormessage = pcall(function() cubeData = cubeDataStore:GetAsync(playerUserId) end) if success then cubesmade.Value = cubeData end end) game.Players.PlayerRemoving:Connect(function(player) local playerUserId = "player_"..player.UserId local cubeValue = player.leaderstats.Cubes.Value local success, errormessage = pcall(function() cubeDataStore:SetAsync(playerUserId, cubeValue) end) end) game:BindToClose(function() for _, player in pairs(game.Players:GetPlayers()) do local playerUserId = "player_"..player.UserId local cubeValue = player.leaderstats.Cubes.Value local success, errormessage = pcall(function() end) cubeDataStore:SetAsync(playerUserId, cubeValue) end end)
Try this
local DSS = game:GetService("DataStoreService") local DataStore = DSS:GetDataStore("CubicData") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Parent = player local Cubes = Instance.new("IntValue") Cubes.Name = "Cubes" Cubes.Parent = leaderstats local data local success, errorMessage = pcall(function() data = DataStore:GetAsync(player.UserId) end) if success and data ~= nil then print("Data successfully loaded!") Cubes.Value = data.Cubes else warn(errorMessage) end end) game.Players.PlayerRemoving:Connect(function(player) local leaderstats = player.leaderstats local data = { Cubes = leaderstats.Cubes.Value; } local success, errorMessage = pcall(function() DataStore:SetAsync(player.UserId,data) end) if success then print("Data successfully saved!") else warn(errorMessage) end end)
Hope this helps!!