I got an inventory in which your hotbar items are displayed and you can equip those through there. Now i need to get a script in which i can make sure the player keeps that inventory when he/she rejoins. I got a script for Wins & Coins which are working right now. I dont understand how to save inventory slots tho. I used intvalues and the leaderstat folder for coins & wins. Following is the script for the inventory:
local player = game.Players.LocalPlayer local character = player.Character local items = {} local buttons = {} game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false) -- Makes the original backpack gui invisible function search(location) for i,v in pairs(location:GetChildren()) do -- Find all item in a specific location if v:isA("Tool") then -- If the item found is a "Tool" table.insert(items,v) -- We're going to put all the tools found in a table. end end end function refresh() for i,v in pairs(buttons) do -- Finds all items in the table v:Destroy() -- Destroy 'em all end for i,v in pairs(items) do -- Finds all items in the table local button = script.Sample:Clone() -- clones the sample button inside the localscript button.Name = v.Name -- sets the cloned button's name to the name of the item button.LayoutOrder = i button.Parent = script.Parent.Handler -- Sets the parent of the cloned button to the handler button.Image = v.TextureId -- Sets the image of the button to the texture id of the tool table.insert(buttons,button) -- Inserts the button to our table "buttons" button.MouseButton1Click:connect(function() if script.Parent.Handler.Selected.Value == nil or script.Parent.Handler.Selected.Value ~= v then -- Checks if the selected value is nothing or if the selected value is not the button script.Parent.Frame.ItemName.Text = v.Name -- Sets the TextLabel's Text to the name of the tool/button script.Parent.Frame.ImageLabel.Image = v.TextureId -- Sets the image label's image to the texture id of the tool script.Parent.Handler.Selected.Value = v if script.Parent.Handler.Selected.Value ~= script.Parent.Handler.Equipped.Value then --if the selected value is not the same as the equipped value then script.Parent.Handler.Location.Value = v.Parent -- Sets the value of our location to the parent of the tool whether it is in the backpack or in the character script.Parent.Frame.Equip.Text = "Equip" -- Self explanatory elseif script.Parent.Handler.Selected.Value == script.Parent.Handler.Equipped.Value then -- If the selected value is the same as the equipped value then... script.Parent.Handler.Location.Value = v.Parent script.Parent.Frame.Equip.Text = "Unequip" end end end) end end function backpackRefresh() items = {} search(character) search(player.Backpack) refresh() end backpackRefresh() player.Backpack.ChildAdded:connect(backpackRefresh) player.Backpack.ChildRemoved:connect(backpackRefresh) character.ChildAdded:connect(backpackRefresh) character.ChildRemoved:connect(backpackRefresh)
This is the link to download the lua file:
https://www.mediafire.com/file/sbqn5dohrc89vbe/backpack+save.lua/file