LocalScript:
local plr = game.Players.LocalPlayer local UIS = game:GetService("UserInputService") plr.PlayerGui:FindFirstChild("InventoryGUI").OpenInventory.Activated:Connect(function() if plr.PlayerGui:FindFirstChild("InventoryGUI").Inventory.Visible == false then plr.PlayerGui:FindFirstChild("InventoryGUI").Inventory.Visible = true else plr.PlayerGui:FindFirstChild("InventoryGUI").Inventory.Visible = false end end)
01:26:17.089 - Players.ArXe66.PlayerScripts.GUIScript:4: attempt to index a nil value
https://gyazo.com/fdf73eb9da959abb3522f3bfe07cc147
i am trying to make a script that opens and closes a GUI window.
line 4
plr.PlayerGui:FindFirstChild("InventoryGUI").OpenInventory.Activated:Connect(function()
Activated
is for Tool not TextButton.
If you want detect when TextButton is clicked, you will need MouseButton1Click
so it will be like this
local plr = game.Players.LocalPlayer local UIS = game:GetService("UserInputService") plr.PlayerGui:FindFirstChild("InventoryGUI").OpenInventory.MouseButton1Click:Connect(function() if plr.PlayerGui:FindFirstChild("InventoryGUI").Inventory.Visible == false then plr.PlayerGui:FindFirstChild("InventoryGUI").Inventory.Visible = true else plr.PlayerGui:FindFirstChild("InventoryGUI").Inventory.Visible = false end end)