Alright, so I've recently found a problem with loading my data. If I rejoin the game with another player present, it will just load his size and his cash. I'm not 100% sure if the problem occurs when saving or loading.
local service = game:GetService("DataStoreService") local datastore = service:GetDataStore("PlayerSize4") game.Players.PlayerAdded:Connect(function(plr) local datatoload = {} local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local size = Instance.new("IntValue") size.Name = "Size" size.Parent = leaderstats local cash = Instance.new("IntValue") cash.Name = "Cash" cash.Parent = leaderstats local success,errorm = pcall(function() datatoload = datastore:GetAsync("Size-"..plr.UserId) end) if success then if datatoload ~= nil then plr.leaderstats.Size.Value = datatoload[1] plr.leaderstats.Cash.Value = datatoload[2] print("Data loaded") end else error("Data could not be loaded.") end end) game.Players.PlayerRemoving:Connect(function(player) local datatosave = {} datatosave[1] = player.leaderstats.Size.Value datatosave[2] = player.leaderstats.Cash.Value local success,errorm = pcall(function() datastore:SetAsync("Size-"..player.UserId, datatosave) end) if success then print("Data saved") else error("An error occured while saving") end end)
Have you enabled access to API Services for your studio? Click Game Settings on home tab, then publish if it requers, click Security and enable this thing
Huh well, the problem seems to have solved itself. I've tried it out again and now everything's working smoothly as it should. Sorry to bother you!