I'm Making a Pokémon RPG and I'd like to delete my gui I created after I pressed a certain Button. Much Appreciated if helped :) I was trying earlier to do : game.Lighting.One:Remove() But it only would kill the file location it wouldn't kill the gui on the screen
--onTouch Gui Shall Appear local Gui = game.Lighting.One - function GiveGui(Player) if Player.PlayerGui:FindFirstChild(Gui.Name)~=nil then return end Gui:Clone().Parent=Player.PlayerGui end script.Parent.Touched:connect(function(hit) local Player=game.Players:GetPlayerFromCharacter(hit.Parent) if Player==nil then return end GiveGui(Player) end) --if _ Keydown delete and create new Gui pcall(game:GetService("UserInputService").InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.A then print 'the key A has been pressed' --THIS IS WHERE I WOULD DELETE MY GUI else print 'Y u no press A?' end end))
To delete it, call Destroy
on the one inside the PlayerGui, like this:
local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild(YourGuiName) if Gui then Gui:Destroy() end
Replacing 'YourGuiName' with the name of the GUI.
Also, your UserInputService stuff needs to be in a local script, while the Touched stuff should probably be in a normal script.