Updating a save when a item is removed? [DESPERATE FOR HELP]
Thing is that my script saves the items in the inventory, but if the item is removed from the inventory it still loads it back (I kind of want consumable items)
-- Load script
01 | game:GetService( "Players" ).PlayerAdded:connect( function (Plr) |
02 | Plr.CharacterAdded:connect( function (Char) |
03 | Plr:WaitForDataReady() |
06 | local lastposition = UDim 2. new( 0 , 0 , 0 , 0 ) |
07 | for _, v in pairs (game:GetService( "ReplicatedStorage" ).Buttons:GetChildren()) do |
08 | if Plr:LoadString(v.Name) = = v.Name then |
10 | print (Plr:LoadString(v.Name)) |
12 | cl.Parent = Plr.PlayerGui.Inventory.Frame.Items |
13 | cl.Position = UDim 2. new( 0 , 14 , 0 , 0 ) + lastposition |
14 | Plr.PlayerGui.Inventory.NumberOfItems.Value = Plr.PlayerGui.Inventory.NumberOfItems.Value + 1 |
17 | lastposition = last.Position + UDim 2. new( 0 , - 14 , 0 , 50 ) |
-- Save script
01 | local Players = game:GetService( "Players" ) |
03 | Players.PlayerAdded:connect( function (Plr) |
04 | Plr.Backpack.ChildAdded:connect( function (Item) |
06 | for _, v in pairs (Plr.PlayerGui.Inventory.Frame.Items:GetChildren()) do |
08 | Plr:SaveString(v.Name,v.Name) |
15 | Players.PlayerRemoving:connect( function (Plr) |
17 | for _, v in pairs (Plr.PlayerGui.Inventory.Frame.Items:GetChildren()) do |
19 | Plr:SaveString(v.Name,v.Name) |
-- These scripts are not finished yet btw, and thanks for any help :P