I can see in the debugger that the InventoryFrame is set to false, but nothing happens. InventoryFrame is a frame consisting of other frames. I will remember to accept a fulfilling answer
1 | InventoryFrame = game.StarterGui.ToolBar.DisplayInventory.InventoryFrame |
2 | script.Parent.Activated:Connect( function () |
3 | if InventoryFrame.Visible = = false then |
4 | InventoryFrame.Visible = true |
5 | else |
6 | InventoryFrame.Visible = false |
7 | end |
8 | end ) |
Simple fix! Make sure you're using a localscript. You can't use the StarterGui.
01 | local Players = game:GetService( "Players" ) |
02 | local PlayerGui = Players.LocalPlayer.PlayerGui |
03 | InventoryFrame = PlayerGui.ToolBar.DisplayInventory.InventoryFrame |
04 | script.Parent.Activated:Connect( function () |
05 | if InventoryFrame.Visible = = false then |
06 | InventoryFrame.Visible = true |
07 | else |
08 | InventoryFrame.Visible = false |
09 | end |
10 | end ) |
Simple version of the if statement (4 lines):
1 | InventoryFrame = game.StarterGui.ToolBar.DisplayInventory.InventoryFrame |
2 | script.Parent.Activated:Connect( function () |
3 | InventoryFrame.Visible = not InventoryFrame.Visible |
4 | end ) |