I'm trying to get it so that it saves the item's name and the item's number in a value (The item is a GUI button, and the value is inside the button called NumberValue)
-- Save
local Players = game:GetService("Players")
Players.PlayerAdded:connect(function(Plr) Plr.Backpack.ChildAdded:connect(function(Item) if Plr.DataReady then for _, v in pairs(Plr.PlayerGui.Inventory.Frame.Items:GetChildren()) do if v ~= nil then Plr:SaveString(v.Name,v.Name) Plr:SaveNumber(v.Name,v.NumberValue.Value) end end end end) end) Players.PlayerRemoving:connect(function(Plr) if Plr.DataReady then for _, v in pairs(Plr.PlayerGui.Inventory.Frame.Items:GetChildren()) do if v ~= nil then Plr:SaveString(v.Name,v.Name) Plr:SaveNumber(v.Name,v.NumberValue.Value) end end end end)
-- Load
game:GetService("Players").PlayerAdded:connect(function(Plr) Plr.CharacterAdded:connect(function(Char) Plr:WaitForDataReady() local last = {} local lastposition = UDim2.new(0, 0, 0, 0) for _, v in pairs(game:GetService("ReplicatedStorage").Buttons:GetChildren()) do if Plr:LoadString(v.Name) == v.Name then if (last) then print(Plr:LoadString(v.Name)) cl = v:Clone() cl.Parent = Plr.PlayerGui.Inventory.Frame.Items cl.Position = UDim2.new(0, 14, 0, 0) + lastposition Plr.PlayerGui.Inventory.NumberOfItems.Value = Plr.PlayerGui.Inventory.NumberOfItems.Value +1 cl.NumberValue.Value = Plr:LoadNumber(v.Value) cl.Number.Text = cl.NumberValue.Value.."x" end last = cl lastposition = last.Position + UDim2.new(0, -14, 0, 48) end end end) end)
You need to share a more detailed issue, just asking if it's right doesn't help us, we need output codes from the game.