[solved] DataStore for tools isn't working with no errors but printing things correctly, any help?
Asked by
3 years ago Edited 3 years ago
I wanted to make a DataStore for tools.
There are no errors whatsoever.
Every number I print is printed in the output but the tools I was expecting isn't coming up.
01 | local dss = game:GetService( 'DataStoreService' ) |
02 | local backpackds = dss:GetDataStore( 'BackpackStore' ) |
04 | game.Players.PlayerAdded:Connect( function (plr) |
05 | local backpack = plr.Backpack |
06 | local data = backpackds:GetAsync(plr.UserId) |
08 | for i, _ in pairs (backpack:GetChildren()) do |
12 | for i,_ in pairs (data) do |
14 | if game.ReplicatedStorage:WaitForChild( 'Tools' ):FindFirstChild(_) then |
16 | local tool = game.ReplicatedStorage.Tools [ _ ] |
17 | local clonedver = tool:Clone() |
23 | plr.CharacterAdded:Connect( function (c) |
24 | c.ChildAdded:Connect( function (_) |
34 | game.Players.PlayerRemoving:Connect( function (plr) |
36 | local backpack = plr.Backpack |
38 | for i, v in pairs (backpack:GetChildren()) do |
39 | table.insert(data,v.Name) |
43 | table.insert(data,equipped.Name) |
46 | local success, msg = pcall ( function () |
47 | backpackds:SetAsync(plr.UserId,data) |
53 | print ( 'Saved Backpack for player' ,plr.Name) |
I check the table in the DataStore plugin and it should've worked.
I deleted all tools since it was the starter tools.
I probably did something wrong getting the data but I don't know what...
Any suggestion/help is appreciated!