Hello. This time, the datastore is not saving value.
local Players = game:GetService("Players")
local DataStore = game:GetService("DataStoreService"):GetDataStore("TestDataStore")
Players.PlayerAdded:Connect(function(player)
local playerId = player.UserId
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local PlayerValue = Instance.new("Folder")
PlayerValue.Name = "PlayerValue"
PlayerValue.Parent = player
local Wins = Instance.new("IntValue")
Wins.Name = "a"
Wins.Parent = leaderstats
local streak = Instance.new("IntValue")
streak.Name = "b"
streak.Parent = leaderstats
local RP = Instance.new("IntValue")
RP.Name = "c"
RP.Parent = leaderstats
local death = Instance.new("IntValue")
death.Name = "d"
death.Parent = leaderstats
local onix = Instance.new("IntValue")
onix.Name = "e"
onix.Parent = PlayerValue
Wins.Value = DataStore:GetAsync(playerId.."-a")
streak.Value = DataStore:GetAsync(playerId.."-b")
death.Value = DataStore:GetAsync(playerId.."-d")
RP.Value = DataStore:GetAsync(playerId.."-c")
onix.Value = DataStore:GetAsync(playerId.."-e")
end)
Players.PlayerRemoving:Connect(function(player)
local leaderstats = player:FindFirstChild("leaderstats")
local PlayerValue = player:FindFirstChild("PlayerValue")
DataStore:SetAsync(player.UserId.."-a",leaderstats.a.Value)
DataStore:SetAsync(player.UserId.."-d",leaderstats.d.Value)
DataStore:SetAsync(player.UserId.."-c",leaderstats.c.Value)
DataStore:SetAsync(player.UserId.."-b",leaderstats.b.Value)
DataStore:SetAsync(player.UserId.."-e",PlayerValue.e.Value)
print("DataSaved")
end)
and then, “DataSaved” is not printing and data is not saving