You need to use :GetAsync() to get the saved data (while :SetAsync() is used to save the data), also instead of ds you have to use the datastore you created which is data. You should use different variable names for the 2 instances you created. To get the data you should do something like:
local success, value = pcall(function()
return data:GetAsync(plr.UserId)
end)
if success then
Character.Value = value
end
I did everything above and what you said it still doesn’t work but i think did something wrong this is my script now:
local ds = game:GetService("DataStoreService")
local data = ds:GetDataStore("Characters")
game.Players.PlayerAdded:Connect(function(plr)
local Character = Instance.new("Folder")
Character.Name = "Characters"
Character.Parent = plr
--Test--
local Test = Instance.new("BoolValue")
Test.Name = "Test"
Test.Parent = plr.Characters
local success, value = pcall(function()
return data:GetAsync(plr.UserId, Test.Value)
end)
if success then
Test.Value = value
end
game.Players.PlayerRemoving:Connect(function(plr)
data:SetAsync(plr.UserId, Test.Value)
end)
end)
local ds = game:GetService("DataStoreService")
local data = ds:GetDataStore("Characters")
game.Players.PlayerAdded:Connect(function(plr)
local Character = Instance.new("Folder")
Character.Name = "Characters"
Character.Parent = plr
--Test--
local Test = Instance.new("BoolValue")
Test.Name = "Test"
Test.Parent = Character
local success, value = pcall(function()
return data:GetAsync(plr.UserId)
end)
if success and value then
Test.Value = value
else
Test.Value = false
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
data:SetAsync(plr.UserId, plr.Characters.Test.Value)
end)