I'm trying to make a GUI appear when you equip a tool and have the GUI disappear when you unequip the tool.
I've tried everything I've could think of. I finally got one step working and then it failed on me. It opens, but it will not close.
local tool = script.Parent
local gui
local function readMenu()
local player = game.Players:getPlayerFromCharacter(tool.Parent)
if player.PlayerGui:findFirstChild("Menu") == nil then
gui = tool.Menu:Clone()
gui.Parent = player.PlayerGui
end
end
local function closeMenu()
wait()
if gui then gui:Menu() end
end
tool.Equipped:connect(readMenu)
tool.Unequipped:connect(closeMenu)

1 comment
In the variables you forgot to give a value to gui