around line 55 it errors

local player = game.Players.LocalPlayer
local character = player.Character
local items = {}
local buttons = {}
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false) --sets this to false I already knew that lmao

function search(location)
	for i,v in pairs(location:GetChildren()) do -- Find all the children
		if v:isA('Tool') then -- If V is a Tool while looping
			table.insert(items,v) -- insert all tools
			
			
		end
	end
end

function refresh()
	for i,v in pairs(buttons) do 
		v:Destroy()
		
	end
	for i,v in pairs(items) do
		local button = script.Sample:Clone()
		button.Name = v.Name
		button.LayoutOrder = i
		button.Parent = script.Parent.Handler
		button.Image = v.TextureId
		table.insert(buttons,button)
		button.MouseButton1Click:Connect(function()
			if script.Parent.Handler.Selected.Value == nil or script.Parent.Handler.Selected.Value ~= v then
				script.Parent.ItemName.Text = v.Name -- sets v Name
				script.Parent.ItemImage.Image = v.TextureId --sets image to text image
				if script.Parent.Handler.Selected.Value ~= script.Parent.Handler.Equip.Value then
					script.Parent.Handler.Location.Value = v.Parent
					script.Parent.Equip.Text = "Equip"
				elseif script.Parent.Handler.Selected.Value == script.Parent.Handler.Equip.Value then
					script.Parent.Handler.Location.Value = v.Parent
					script.Parent.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)

									-- I assume error is somewhere here 
	
character.Backpack.ChildAdded:Connect(backpackRefresh)

character.Backpack.ChildRemoved:Connect(backpackRefresh)

it keeps giving me error

2 comments

0

Which line is line 55... You gave us 15 lines.

0

Backpack is a member of the Player instance, not the Character Model.