local DataStore = game:GetService("DataStoreService")
local MyData = DataStore:GetDataStore("MyData2")
game.Players.PlayerAdded:Connect(function(player)
local Folder = Instance.new("Folder")
Folder.Name = "Stats"
Folder.Parent = player
local Speed = Instance.new("IntValue")
Speed.Name = "Speed"
Speed.Parent = Folder
local Strength = Instance.new("IntValue")
Strength.Name = "Strength"
Strength.Parent = Folder
local Stamina = Instance.new("IntValue")
Stamina.Name = "Stamina"
Stamina.Parent = Folder
Stamina.Value = 100
local playerUserId = "Player_"..player.UserId
local data
local success, errormessage = pcall(function()
data = MyData:GetAsync(playerUserId)
end)
if success then
if data then
Strength.Value = data.Strength
Speed.Value = data.Speed
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local data = {
Strength = player.Stats.Strength.Value;
Speed = player.Stats.Speed.Value
}
local playerUserId = "Player_"..player.UserId
local success, errormessage = pcall(function()
MyData:SetAsync(playerUserId, data)
end)
if success then
print("data saved")
else
print("error")
end
end)
COMMUNITY QUESTION
Why will this datastore only save Strength instead of both Strength and Speed?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
are you kicking the player to remove them? Assuming this is done in studio