So basically I've made a DataStore containing 4 values but it didn't load nor save those 4 values it contained and I swear the last time I've made a DataStore containing more than 1 values worked! But this time it didn't! Please check my script.
local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService:GetDataStore("Leaderstats") game.Players.PlayerAdded:Connect(function(Player) local Leaderstats = Instance.new("Folder",Player) Leaderstats.Name = "Leaderstats" local Coins = Instance.new("IntValue",Leaderstats) Coins.Name = "Coins" local Written = Instance.new("IntValue",Leaderstats) Written.Name = "Written" local Gems = Instance.new("IntValue",Leaderstats) Gems.Name = "Gems" local Restarts = Instance.new("IntValue",Leaderstats) Restarts.Name = "Restarts" local LoadedCoins = 0 local LoadedWritten = 0 local LoadedGems = 0 local LoadedRestarts = 0 local Success,Failed = pcall(function() LoadedCoins = DataStore:GetAsync(Player.UserId.."Coins") LoadedWritten = DataStore:GetAsync(Player.UserId.."Written") LoadedGems = DataStore:GetAsync(Player.UserId.."Gems") LoadedRestarts = DataStore:GetAsync(Player.UserId.."Restarts") end) if Success then Coins.Value = LoadedCoins Written.Value = LoadedWritten Gems.Value = LoadedGems Restarts.Value = LoadedRestarts else warn(Failed) end end) game.Players.PlayerRemoving:Connect(function(Player) local Success,Failed = pcall(function() DataStore:SetAsync(Player.UserId.."Coins",Player.Leaderstats.Coins.Value) DataStore:SetAsync(Player.UserId.."Written",Player.Leaderstats.Written.Value) DataStore:SetAsync(Player.UserId.."Gems",Player.Leaderstats.Gems.Value) DataStore:SetAsync(Player.UserId.."Restarts",Player.Leaderstats.Restarts.Value) end) if Success then print("Successfully saved "..Player.Name.."'s data!") else warn(Failed) end end)
If your trying to see if its saving and loading in Roblox Studio, It will only load It can't save in Roblox Studio. Try in a regular server. Or see if you have not turned on API Serivces.
Using Data Stores in Studio DataStoreService cannot be used in Studio if a game is not configured to allow access to API services. See the Data Stores article for instructions.