My second destrouctor isn't destructing my Gui. I have already created a Gui. Then I need to press tab to destruct. But the issue is it doesn't destruct.
--------------------------------DESTROUCTOR
game:GetService("UserInputService").InputBegan:connect(function(key)
if key.KeyCode == Enum.KeyCode.Tab then
print 'the key Tab has been pressed'
local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("One")
if Gui then
Gui:Destroy()
end
end
end)
----------------------CREATOR-------------------------------------------
game:GetService("UserInputService").InputBegan:connect(function(key)
if key.KeyCode == Enum.KeyCode.Tab then
player = game.Players.LocalPlayer
gui = game.Lighting.Two
gui:Clone().Parent = player.PlayerGui
end
end)
-------------------HERE IS MY SECOND DESTROUCTER
game:GetService("UserInputService").InputBegan:connect(function(key)
if key.KeyCode == Enum.KeyCode.Tab then
local GuiTwo = game.Players.LocalPlayer.PlayerGui:FindFirstChild("Two")
if GuiTwo then
GuiTwo:Destroy()
end
end
end)

7 comments
You have linked these all to the same event and to the same key code so they should all run. See the problem?
No not really Im making a rpg where you need to press tab to move on to the next Gui of text
Just put all of your logic into one of the InputBegan events and remove the others. Check the current gui then move to the next one.
What do you mean?
When you press the tab you want to check what gui the player currently has then delete and give them the next gui. simple
So how shall I do that? Thank for your patience as I'm not one with lua
Halp