Help with inventory 5

Hello, Hi

I have an Inventory system which equips items and sends them to your backpack, I just need them to be sent to a folder in ServerStorage, and only one item can be in ServerStorage at all times
It already has equipping and unequipping, but it doesnt work that well, when you equip the tool, it should send it to the folder in ServerStorage and when you equip another tool, it takes back the first tool and sends the second tool to the folder in ServerStorage

I dont really know how to send it to ServerStorage, because I am a noob at scripting

local player = game.Players.LocalPlayer
local character = player.Character
local items = {}
local buttons = {}
local ListaGui = script.Parent.Frame.ScrollingFrame
local EquipGui = script.Parent.Frame.Equipar


game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false) 


function buscar(location)
	for i,v in pairs(location:GetChildren()) do 
		if v:isA("Tool") then 
			table.insert(items,v)
		end
	end
end

function actualizar()
	for i,v in pairs(buttons) do 
		v:Destroy() 
	end

	
	for i,item in pairs(items) do
		local button = script.Button:Clone() 
		button.Name = item.Name 
		button.LayoutOrder = i
		button.Parent = ListaGui 
		button.Image = item.TextureId 
		button.BackgroundTransparency = 1
		table.insert(buttons,button) 
		button.MouseButton1Click:connect(function()
			local ListaGui = script.Parent.Frame.ScrollingFrame
			local EquipGui = script.Parent.Frame.Equipar
			if ListaGui.Selected.Value == nil or ListaGui.Selected.Value ~= item then 
				
				EquipGui.ItemName.Text = item.Name
				EquipGui.ImageLabel.Image = item.TextureId 
				ListaGui.Selected.Value = item
				if ListaGui.Selected.Value ~= ListaGui.Equipped.Value then 
					ListaGui.Location.Value = item.Parent 
					EquipGui.Equip.Text = "Equip" 
				elseif ListaGui.Selected.Value == ListaGui.Equipped.Value then 
					ListaGui.Location.Value = item.Parent
					EquipGui.Equip.Text = "Unequip"
				end
			end
		end)
	end
end



function backpackRefresh()
	items = {}
	buscar(character)
	buscar(player.Backpack)
	actualizar()
end

backpackRefresh()

player.Backpack.ChildAdded:connect(backpackRefresh)
player.Backpack.ChildRemoved:connect(backpackRefresh)

character.ChildAdded:connect(backpackRefresh)
character.ChildRemoved:connect(backpackRefresh)




local EquipButton = EquipGui.Equip

EquipButton.MouseButton1Click:connect(function()
	
	local equipped = ListaGui.Equipped
	local selected =  ListaGui.Selected
	local location =  ListaGui.Location
	local player = game.Players.LocalPlayer
	local character = player.Character
	if equipped.Value == nil or equipped.Value ~= selected.Value then 
		character.Humanoid:UnequipTools() 
		if location.Value == player.Backpack then
			character.Humanoid:EquipTool(selected.Value)
			equipped.Value = selected.Value
			EquipButton.Text = "Unequip"
		end
	else
		character.Humanoid:UnequipTools()
		equipped.Value = nil
		EquipButton.Text = "Equip"
	end
end)

I think you edit the if location = backpack then

But im not too sure

Thanks for helping, or just reading, i guess

This looks like a local script,

Local Scripts cannot access / modify the descendants of Server Storage.

1 Like

Ok, so what can I do when I change it into a script

If you want the script to be a local one you can simply move the referenced instances from the ā€˜ServerStorageā€™ container to the ā€˜ReplicatedStorageā€™ container.

So I put the folder with the tools in Replicated Storage? Ok, I can do that

However, I still dont know where to edit the script

Youā€™d need to change references from ā€˜game.ServerStorageā€™ to ā€˜game.ReplicatedStorageā€™ instead.

there is no game.ServerStorage

there is player.backpack which the tools currently go in to