Hi I was wondering why this piece of code wont work?
local datastore = game:GetService("DataStoreService"):GetDataStore("Stats") game.Players.PlayerRemoving:connect(function(player) player:WaitForDataReady() datastore:SetAsync(player.Backpack:findFirstChild("Data"),player.Data.Value) datastore:SetAsync(player.Backpack:findFirstChild("Type").Name,player.Type.Value) datastore:SetAsync(player.Backpack:findFirstChild("Bp").Name,player.Bp.Value) end) game.Players.PlayerAdded:connect(function(newplayer) newplayer:WaitForDataReady() if datastore:GetAsync(newplayer.Backpack.Type.Value) ~= 0 then Type.Value = datastore:GetAsync(newplayer.Backpack.Type.Value) if datastore:GetAsync(newplayer.Backpack.Bp.Value) ~= "None" then newplayer.Bp.Value = datastore:GetAsync(newplayer.Backpack.Bp.Value) end end
end)
Thanks
It looks like player.Backpack:findFirstChild("Data")
is supposed to be player.Backpack:findFirstChild("Data").Name
based on the surrounding code and the fact that the first parameter of DataStore:SetAsync expects a string.