Why is my weapon saving script not saving new weapons?
THIS SCRIPT ALWAYS WORKS BUT ITS ONLY LOADING WEAPONS WHEN U JOIN AND NOT SAVING THEM WHEN U LEAVE SO IF U GET A NEW WEAPON IS DOESNT SAVE PLS HELP ME
01 | local ds = game:GetService( "DataStoreService" ):GetDataStore( "ToolSave" ) |
02 | game.Players.PlayerAdded:Connect( function (plr) |
03 | local key = "id-" ..plr.userId |
05 | local tools = ds:GetAsync(key) |
07 | for i,v in pairs (tools) do |
08 | local tool = game.ServerStorage.Tools:FindFirstChild(v) |
10 | tool:Clone().Parent = plr:WaitForChild( "Backpack" ) |
11 | tool:Clone().Parent = plr:WaitForChild( "StarterGear" ) |
18 | game.Players.PlayerRemoving:Connect( function (plr) |
19 | local key = "id-" ..plr.userId |
21 | local toolsToSave = { } |
22 | for i,v in pairs (plr.Backpack:GetChildren()) do |
24 | table.insert(toolsToSave,v.Name) |
27 | for fuck, you in pairs (plr.Character:GetChildren()) do |
28 | if you.ClassName = = "Tool" then |
29 | table.insert(toolsToSave,you.Name) |
32 | ds:SetAsync(key,toolsToSave) |