When a tool is equipped, the Gui clones and the player can see it. That works fine. The problem is that when it's unequipped, it doesn't destroy the Gui. On the output it says something like "attempted to index guiMain, a nil value". Anyone know how to fix this?
Tool = script.Parent guiMain = nil function onEquippedLocal() local character = script.Parent.Parent local player = game.Players:GetPlayerFromCharacter(character) local guiMain = script.Parent.AirportControl:clone() guiMain.Parent = player.PlayerGui end function onUnequippedLocal() guiMain:Destroy() end Tool.Equipped:connect(onEquippedLocal) Tool.Unequipped:connect(onUnequippedLocal)
I removed the "local" in front of "local guiMain" on line 7 and fixed it. :)