Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I have created some code that deletes and clones code. I ran into error with this " end)"?

Thanks in advance. The code basically deletes a Gui I made earlier if I press tab Now It'll Clone another gui inplace of that. Now I want to press tab to delete it? Code:

--if _ Keydown delete and create new Gui
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
------------------------------------------------------------------------------------
	player = game.Players.LocalPlayer
	gui = game.Lighting.Two
	
	gui:Clone().Parent = player.PlayerGui
	local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("Two")
	if Gui then Gui:Destroy() 
	
	
------------------------------------------------------------------------------------
	
-------------

end
end) --ERROR 

1 comment

0

This is why it is good to tab your code.

1 answer

✓ Accepted answer

You're just missing and end on line 14.

Easy mistake.

--if _ Keydown delete and create new Gui
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
------------------------------------------------------------------------------------
    player = game.Players.LocalPlayer
    gui = game.Lighting.Two

    gui:Clone().Parent = player.PlayerGui
    local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("Two")
    if Gui then Gui:Destroy() end -- added end


------------------------------------------------------------------------------------

-------------

end
end) --ERROR

Good Luck

If I helped, please don't forget to accept my answer!

2 comments

0

Issue though. It does clone the second line then?

0

What?

This discussion is preserved as it was. New answers, comments, and votes are closed.