Hello! Im trying to save player data, and am having issues with saving it. It doesn't run the pcalls at all, and wondered if im missing something?
local dss = game:GetService("DataStoreService") local ds = dss:GetDataStore("PlayerStatistics") game.Players.PlayerAdded:Connect(function(player) print("PlayerAdded") local Statistics = Instance.new("Folder", player); Statistics.Name = "Statistics" local Money = Instance.new("IntValue", Statistics); Money.Name = "Money" local Population = Instance.new("IntValue", Statistics); Population.Name = "Population" local Souls = Instance.new("IntValue", Statistics); Souls.Name = "Souls" local MoneyLoaded local PopulationLoaded local SoulsLoaded local success, errormessage = pcall(function() MoneyLoaded = ds:GetAsync(player.UserId.."-money") PopulationLoaded = ds:GetAsync(player.UserId.."-population") SoulsLoaded = ds:GetAsync(player.UserId.."-souls") end) if success then Money.Value = MoneyLoaded Population.Value = PopulationLoaded Souls.Value = SoulsLoaded print(player.Statistics.Money.Value) print(player.Statistics.Population.Value) print(player.Statistics.Souls.Value) else print("Error occured during data get") warn(errormessage) end end) game.Players.PlayerRemoving:Connect(function(player) print("PlayerRemoved") local success, errormessage = pcall(function() ds:SetAsync(player.UserId.."-money", player.Statistics.Money.value) ds:SetAsync(player.UserId.."-population", player.Statistics.Population.value) ds:SetAsync(player.UserId.."-souls", player.Statistics.Souls.value) print(player.Statistics.Money.Value) print(player.Statistics.Population.Value) print(player.Statistics.Souls.Value) end) if success then print("Data saved successfully") else print("An error occured") warn(errormessage) end end)