You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to achieve a DataStore system that duplicates a folder, parents it to replicated storage, sets data or gets the data. -
What is the issue? Include screenshots / videos if possible!
However, a part of the script is not working which is the SetAsync part.
I found out by using prints(), heres a image.
It does not print what it says after SetAsync.
I have been looking at this for more than 30 minutes and still cannot find a solution, and it is apart of the player removing function,
game.Players.PlayerRemoving:Connect(function(plr)
print(plr.Name .. "Left")
local dataStore = dataStore_Service:GetDataStore(plr.UserId .. "Info")
local zombieBio = game.ReplicatedStorage:FindFirstChild(plr.Name .. " Information")
local info = zombieBio:GetDescendants()
print("Got descendants")
for index, descendant in pairs(info) do
if descendant:IsA('StringValue') or descendant:IsA('BoolValue') or descendant:IsA('IntValue') then
print(descendant.Name .. "Is descendant of" .. plr.Name)
dataStore:SetAsync(descendant.Name, descendant.Value)
print("set async")
end
end
zombieBio:Destroy()
end)
This is my entire script which might not be too useful since I think this only has to do with the playerRemoving function.
local dataStore_Service = game:GetService("DataStoreService")
game.Players.PlayerAdded:Connect(function(plr)
print(plr.Name .. "added")
local dataStore = dataStore_Service:GetDataStore(plr.UserId .. "Info")
local zombieBio = game.ReplicatedStorage.ZombieBio:Clone()
zombieBio.Name = plr.Name .. " Information"
zombieBio.Parent = game.ReplicatedStorage
local info = zombieBio:GetDescendants()
print("Got descendants")
for index, descendant in pairs(info) do
if descendant:IsA('StringValue') or descendant:IsA('BoolValue') or descendant:IsA('IntValue') then
print(descendant.Name .. "Is descendant of" .. plr.Name)
descendant.Value = dataStore:GetAsync(descendant.Name)
print("got async")
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
print(plr.Name .. "Left")
local dataStore = dataStore_Service:GetDataStore(plr.UserId .. "Info")
local zombieBio = game.ReplicatedStorage:FindFirstChild(plr.Name .. " Information")
local info = zombieBio:GetDescendants()
print("Got descendants")
for index, descendant in pairs(info) do
if descendant:IsA('StringValue') or descendant:IsA('BoolValue') or descendant:IsA('IntValue') then
print(descendant.Name .. "Is descendant of" .. plr.Name)
dataStore:SetAsync(descendant.Name, descendant.Value)
print("set async")
end
end
zombieBio:Destroy()
end)
I am not too experienced with DataStores so I have no idea why this does not work.