Im trying to make a custom inventory script and when you click on the tool you want to equipped a side bar with all the info of the tool come up but the close button for the sidebar "Inbar" does not work. also the inventory opens fine in studio but does not open in the game when you click the open button, it used to open fine but after doing the localscript to put all the tool into the custom inventory the open button stopped working. I don't Know if there a problem with the script or if its just roblox studio not working. any help would be appreciated.

localscript in starter GUI

local player = game.Players.LocalPlayer
local character = player.Character
local items = {}
local buttons = {}
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false) 

function search(location)
	for i,v in pairs(location:GetChildren()) do
		if v:isA("Tool") then 
			table.insert(items,v) 
		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.MainInventory.Scroller 
		button.Image = v.TextureId
		table.insert(buttons,button)
		button.MouseButton1Click:connect(function()
			
			script.Parent.InBar.Visible = true
			
		
			if script.Parent.MainInventory.Scroller.Selected.Value == nil or script.Parent.MainInventory.Scroller.Selected.Value ~= v then
				print("visivle = true")
				script.Parent.InBar.BackGround.ItemName.Text = v.Name 
				script.Parent.InBar.BackGround.ImageLabel.Image = v.TextureId 
				script.Parent.MainInventory.Scroller.Selected.Value = v
				if script.Parent.MainInventory.Scroller.Selected.Value ~= script.Parent.MainInventory.Scroller.Equipped.Value then 
					script.Parent.MainInventory.Scroller.Location.Value = v.Parent 
					script.Parent.InBar.BackGround.Equip.Text = "Equip" 
				elseif script.Parent.MainInventory.Scroller.Selected.Value == script.Parent.MainInventory.Scroller.Equipped.Value then 
					script.Parent.InBar.BackGround.Equip.Text = "Unequip"
					
				end
				end
				
	
		
		end)
	end	
end

function backpackfresh()
	items = {}
	search(character)
	search(player.Backpack)
	refresh()
end

backpackfresh()

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

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

script in closeBar

script.Parent.MouseButton1Click:Connect(function()
	local inBar = script.Parent.Parent.Parent.Parent.InBar
	
			print("works")
		inBar.Visible = false

		
end)

script in open inventory

script.Parent.MouseButton1Click:Connect(function()
	local mainInventory = script.Parent.Parent.Parent.MainInventory
	local line = script.Parent.Parent.Parent.Parent.BackpackGUI.Line
	local scroller = script.Parent.Parent.Parent.MainInventory.Scroller
	local boddy = script.Parent.Parent.Parent.Parent.BackpackGUI.Boddy
	local inbar = script.Parent.Parent.Parent.InBar
	
	if mainInventory.Visible == false then
		mainInventory.Visible = true
	end	
	
	if line.Visible == false then
		line.Visible = true
	end	
	
	if scroller.Visible == false then
		scroller.Visible = true
	end	
	if boddy.Visible == false then
		boddy.Visible = true
	end
	
	
		if inbar.Visible == false then
		inbar.Visible = true
	end
end)