Is there a function to toggle the visibility of Items?
Currently i set it up where if you press g the background or grid will disappear. However the items are still there and Iāve no idea how to toggle their visibility
My Code:
--//UtilityFunctions
function GridUi:NewGrid(Visible, GridSize, SlotAspectRatio, AnchorPoint, Position, Size)
--//MainScreen
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "GridPack"
ScreenGui.ResetOnSpawn = false
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
ScreenGui.Parent = game:GetService("Players").LocalPlayer.PlayerGui
--//Grids
local GridPack = GridModule.createGrid({
Parent = ScreenGui, -- Parent of the grid container.
Visible = Visible, -- If the grid is visible, changes the containers visible property. Also disables item interaction on all items inside. BY DEFAULT THIS IS SET TO FALSE to prevent the inventory being shown when first creating the Grid.
Assets = {
Slot = nil, -- Add your own CanvasGroup here to customize the slots in the grid.
},
GridSize = GridSize, -- How many slots the grid has on the X and Y axes.
SlotAspectRatio = SlotAspectRatio, -- Aspect ratio of one slot in the grid, helps with different resolutions if you're using scale instead of offset.
AnchorPoint = AnchorPoint, -- Anchor point of the grid container.
Position = Position, -- Position of the grid container.
Size = Size, -- Size of the grid container.
Metadata = {
-- Here you are free to store any values you want.
},
})
local TransferGrid = GridModule.createGrid({
Parent = ScreenGui,
Visible = true,
GridSize = Vector2.new(8, 15),
SlotAspectRatio = 1,
AnchorPoint = Vector2.new(1, 0.5),
Position = UDim2.new(1, -20, 0.5, 0),
Size = UDim2.fromScale(0.25, 0.5),
})
--//TransferLinks
local TransferLink = GridModule.createTransferLink({}) -- Create TransferLink
GridPack:ConnectTransferLink(TransferLink) -- Connect TransferLink to our first grid.
TransferGrid:ConnectTransferLink(TransferLink) -- Connect the TransferLink to our new grid.
--//Items
GridUi:NewItem(GridPack, Vector2.new(0, 0), Vector2.new(2, 2))
GridUi:NewItem(GridPack, Vector2.new(0, 2), Vector2.new(4, 4))
GridUi:NewItem(GridPack, Vector2.new(0, 6), Vector2.new(6, 6))
GridUi:NewItem(TransferGrid, Vector2.new(0, 0), Vector2.new(2, 4))
GridUi:NewItem(TransferGrid, Vector2.new(0, 4), Vector2.new(1, 3))
GridUi:NewItem(TransferGrid, Vector2.new(0, 8), Vector2.new(2, 2))
--//Functions
function GridUi:ToggleInventory()
GridPack.GuiElement.Visible = not GridPack.GuiElement.Visible
TransferGrid.GuiElement.Visible = not TransferGrid.GuiElement.Visible
end
end
Userinput code:
UserInputService.InputBegan:Connect(function(Input, IsTyping, GPE)
if IsTyping == true or GPE == true then return end
Maid:GiveTask(task.spawn(function()
if Input.KeyCode == Enum.KeyCode.G then
GridModule.ToggleInventory()
end
end))
end)
GridModule:NewGrid(true,Vector2.new(8, 15),1,Vector2.new(0, 0.5),UDim2.new(0, 20, 0.5, 0),UDim2.fromScale(0.25, 0.5))